diff --git a/Dataflow/src/V1beta3/Client/FlexTemplatesServiceClient.php b/Dataflow/src/V1beta3/Client/FlexTemplatesServiceClient.php index 1df56cf9b181..03a9fe2b24da 100644 --- a/Dataflow/src/V1beta3/Client/FlexTemplatesServiceClient.php +++ b/Dataflow/src/V1beta3/Client/FlexTemplatesServiceClient.php @@ -29,6 +29,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; use Google\ApiCore\ValidationException; @@ -99,25 +100,28 @@ private static function getClientDefaults() /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dataflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dataflow\V1beta3\FlexTemplatesServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new FlexTemplatesServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -155,13 +159,15 @@ private static function getClientDefaults() * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException * * @experimental */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -202,10 +208,8 @@ public function __call($method, $args) * * @experimental */ - public function launchFlexTemplate( - LaunchFlexTemplateRequest $request, - array $callOptions = [] - ): LaunchFlexTemplateResponse { + public function launchFlexTemplate(LaunchFlexTemplateRequest $request, array $callOptions = []): LaunchFlexTemplateResponse + { return $this->startApiCall('LaunchFlexTemplate', $request, $callOptions)->wait(); } } diff --git a/Dataflow/src/V1beta3/Client/JobsV1Beta3Client.php b/Dataflow/src/V1beta3/Client/JobsV1Beta3Client.php index e94b895bd3a9..e2967aff01fa 100644 --- a/Dataflow/src/V1beta3/Client/JobsV1Beta3Client.php +++ b/Dataflow/src/V1beta3/Client/JobsV1Beta3Client.php @@ -29,6 +29,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; @@ -114,25 +115,28 @@ private static function getClientDefaults() /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dataflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dataflow\V1beta3\JobsV1Beta3Client; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new JobsV1Beta3Client(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -170,13 +174,15 @@ private static function getClientDefaults() * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException * * @experimental */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/Dataflow/src/V1beta3/Client/MessagesV1Beta3Client.php b/Dataflow/src/V1beta3/Client/MessagesV1Beta3Client.php index f099c75fd8a4..3f31933c89db 100644 --- a/Dataflow/src/V1beta3/Client/MessagesV1Beta3Client.php +++ b/Dataflow/src/V1beta3/Client/MessagesV1Beta3Client.php @@ -29,6 +29,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; @@ -100,25 +101,28 @@ private static function getClientDefaults() /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dataflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dataflow\V1beta3\MessagesV1Beta3Client; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new MessagesV1Beta3Client(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -156,13 +160,15 @@ private static function getClientDefaults() * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException * * @experimental */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/Dataflow/src/V1beta3/Client/MetricsV1Beta3Client.php b/Dataflow/src/V1beta3/Client/MetricsV1Beta3Client.php index da3378ad241c..56e93ac5c8c6 100644 --- a/Dataflow/src/V1beta3/Client/MetricsV1Beta3Client.php +++ b/Dataflow/src/V1beta3/Client/MetricsV1Beta3Client.php @@ -29,6 +29,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; @@ -105,25 +106,28 @@ private static function getClientDefaults() /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dataflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dataflow\V1beta3\MetricsV1Beta3Client; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new MetricsV1Beta3Client(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -161,13 +165,15 @@ private static function getClientDefaults() * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException * * @experimental */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -210,10 +216,8 @@ public function __call($method, $args) * * @experimental */ - public function getJobExecutionDetails( - GetJobExecutionDetailsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function getJobExecutionDetails(GetJobExecutionDetailsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('GetJobExecutionDetails', $request, $callOptions); } @@ -278,10 +282,8 @@ public function getJobMetrics(GetJobMetricsRequest $request, array $callOptions * * @experimental */ - public function getStageExecutionDetails( - GetStageExecutionDetailsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function getStageExecutionDetails(GetStageExecutionDetailsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('GetStageExecutionDetails', $request, $callOptions); } } diff --git a/Dataflow/src/V1beta3/Client/SnapshotsV1Beta3Client.php b/Dataflow/src/V1beta3/Client/SnapshotsV1Beta3Client.php index 5c649e89aff9..e14c1dafe979 100644 --- a/Dataflow/src/V1beta3/Client/SnapshotsV1Beta3Client.php +++ b/Dataflow/src/V1beta3/Client/SnapshotsV1Beta3Client.php @@ -29,6 +29,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; use Google\ApiCore\ValidationException; @@ -105,25 +106,28 @@ private static function getClientDefaults() /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dataflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dataflow\V1beta3\SnapshotsV1Beta3Client; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new SnapshotsV1Beta3Client(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -161,13 +165,15 @@ private static function getClientDefaults() * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException * * @experimental */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/Dataflow/src/V1beta3/Client/TemplatesServiceClient.php b/Dataflow/src/V1beta3/Client/TemplatesServiceClient.php index 32789fe14bc4..73746152d56b 100644 --- a/Dataflow/src/V1beta3/Client/TemplatesServiceClient.php +++ b/Dataflow/src/V1beta3/Client/TemplatesServiceClient.php @@ -29,6 +29,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; use Google\ApiCore\ValidationException; @@ -105,25 +106,28 @@ private static function getClientDefaults() /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dataflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dataflow\V1beta3\TemplatesServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new TemplatesServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -161,13 +165,15 @@ private static function getClientDefaults() * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException * * @experimental */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/Dataform/src/V1/Client/DataformClient.php b/Dataform/src/V1/Client/DataformClient.php index 985b69aa2f07..5e473825e164 100644 --- a/Dataform/src/V1/Client/DataformClient.php +++ b/Dataform/src/V1/Client/DataformClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -257,12 +258,8 @@ private static function getClientDefaults() * * @return string The formatted compilation_result resource. */ - public static function compilationResultName( - string $project, - string $location, - string $repository, - string $compilationResult - ): string { + public static function compilationResultName(string $project, string $location, string $repository, string $compilationResult): string + { return self::getPathTemplate('compilationResult')->render([ 'project' => $project, 'location' => $location, @@ -321,13 +318,8 @@ public static function cryptoKeyName(string $project, string $location, string $ * * @return string The formatted crypto_key_version resource. */ - public static function cryptoKeyVersionName( - string $project, - string $location, - string $keyRing, - string $cryptoKey, - string $cryptoKeyVersion - ): string { + public static function cryptoKeyVersionName(string $project, string $location, string $keyRing, string $cryptoKey, string $cryptoKeyVersion): string + { return self::getPathTemplate('cryptoKeyVersion')->render([ 'project' => $project, 'location' => $location, @@ -364,11 +356,8 @@ public static function locationName(string $project, string $location): string * * @return string The formatted notebook_runtime_template resource. */ - public static function notebookRuntimeTemplateName( - string $project, - string $location, - string $notebookRuntimeTemplate - ): string { + public static function notebookRuntimeTemplateName(string $project, string $location, string $notebookRuntimeTemplate): string + { return self::getPathTemplate('notebookRuntimeTemplate')->render([ 'project' => $project, 'location' => $location, @@ -387,12 +376,8 @@ public static function notebookRuntimeTemplateName( * * @return string The formatted release_config resource. */ - public static function releaseConfigName( - string $project, - string $location, - string $repository, - string $releaseConfig - ): string { + public static function releaseConfigName(string $project, string $location, string $repository, string $releaseConfig): string + { return self::getPathTemplate('releaseConfig')->render([ 'project' => $project, 'location' => $location, @@ -450,12 +435,8 @@ public static function secretVersionName(string $project, string $secret, string * * @return string The formatted workflow_config resource. */ - public static function workflowConfigName( - string $project, - string $location, - string $repository, - string $workflowConfig - ): string { + public static function workflowConfigName(string $project, string $location, string $repository, string $workflowConfig): string + { return self::getPathTemplate('workflowConfig')->render([ 'project' => $project, 'location' => $location, @@ -475,12 +456,8 @@ public static function workflowConfigName( * * @return string The formatted workflow_invocation resource. */ - public static function workflowInvocationName( - string $project, - string $location, - string $repository, - string $workflowInvocation - ): string { + public static function workflowInvocationName(string $project, string $location, string $repository, string $workflowInvocation): string + { return self::getPathTemplate('workflowInvocation')->render([ 'project' => $project, 'location' => $location, @@ -500,12 +477,8 @@ public static function workflowInvocationName( * * @return string The formatted workspace resource. */ - public static function workspaceName( - string $project, - string $location, - string $repository, - string $workspace - ): string { + public static function workspaceName(string $project, string $location, string $repository, string $workspace): string + { return self::getPathTemplate('workspace')->render([ 'project' => $project, 'location' => $location, @@ -552,25 +525,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dataform.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dataform\V1\DataformClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new DataformClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -608,11 +584,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -650,10 +628,8 @@ public function __call($method, $args) * * @throws ApiException Thrown if the API call fails. */ - public function cancelWorkflowInvocation( - CancelWorkflowInvocationRequest $request, - array $callOptions = [] - ): CancelWorkflowInvocationResponse { + public function cancelWorkflowInvocation(CancelWorkflowInvocationRequest $request, array $callOptions = []): CancelWorkflowInvocationResponse + { return $this->startApiCall('CancelWorkflowInvocation', $request, $callOptions)->wait(); } @@ -679,10 +655,8 @@ public function cancelWorkflowInvocation( * * @throws ApiException Thrown if the API call fails. */ - public function commitRepositoryChanges( - CommitRepositoryChangesRequest $request, - array $callOptions = [] - ): CommitRepositoryChangesResponse { + public function commitRepositoryChanges(CommitRepositoryChangesRequest $request, array $callOptions = []): CommitRepositoryChangesResponse + { return $this->startApiCall('CommitRepositoryChanges', $request, $callOptions)->wait(); } @@ -707,10 +681,8 @@ public function commitRepositoryChanges( * * @throws ApiException Thrown if the API call fails. */ - public function commitWorkspaceChanges( - CommitWorkspaceChangesRequest $request, - array $callOptions = [] - ): CommitWorkspaceChangesResponse { + public function commitWorkspaceChanges(CommitWorkspaceChangesRequest $request, array $callOptions = []): CommitWorkspaceChangesResponse + { return $this->startApiCall('CommitWorkspaceChanges', $request, $callOptions)->wait(); } @@ -736,10 +708,8 @@ public function commitWorkspaceChanges( * * @throws ApiException Thrown if the API call fails. */ - public function computeRepositoryAccessTokenStatus( - ComputeRepositoryAccessTokenStatusRequest $request, - array $callOptions = [] - ): ComputeRepositoryAccessTokenStatusResponse { + public function computeRepositoryAccessTokenStatus(ComputeRepositoryAccessTokenStatusRequest $request, array $callOptions = []): ComputeRepositoryAccessTokenStatusResponse + { return $this->startApiCall('ComputeRepositoryAccessTokenStatus', $request, $callOptions)->wait(); } @@ -764,10 +734,8 @@ public function computeRepositoryAccessTokenStatus( * * @throws ApiException Thrown if the API call fails. */ - public function createCompilationResult( - CreateCompilationResultRequest $request, - array $callOptions = [] - ): CompilationResult { + public function createCompilationResult(CreateCompilationResultRequest $request, array $callOptions = []): CompilationResult + { return $this->startApiCall('CreateCompilationResult', $request, $callOptions)->wait(); } @@ -870,10 +838,8 @@ public function createWorkflowConfig(CreateWorkflowConfigRequest $request, array * * @throws ApiException Thrown if the API call fails. */ - public function createWorkflowInvocation( - CreateWorkflowInvocationRequest $request, - array $callOptions = [] - ): WorkflowInvocation { + public function createWorkflowInvocation(CreateWorkflowInvocationRequest $request, array $callOptions = []): WorkflowInvocation + { return $this->startApiCall('CreateWorkflowInvocation', $request, $callOptions)->wait(); } @@ -1070,10 +1036,8 @@ public function fetchFileDiff(FetchFileDiffRequest $request, array $callOptions * * @throws ApiException Thrown if the API call fails. */ - public function fetchFileGitStatuses( - FetchFileGitStatusesRequest $request, - array $callOptions = [] - ): FetchFileGitStatusesResponse { + public function fetchFileGitStatuses(FetchFileGitStatusesRequest $request, array $callOptions = []): FetchFileGitStatusesResponse + { return $this->startApiCall('FetchFileGitStatuses', $request, $callOptions)->wait(); } @@ -1098,10 +1062,8 @@ public function fetchFileGitStatuses( * * @throws ApiException Thrown if the API call fails. */ - public function fetchGitAheadBehind( - FetchGitAheadBehindRequest $request, - array $callOptions = [] - ): FetchGitAheadBehindResponse { + public function fetchGitAheadBehind(FetchGitAheadBehindRequest $request, array $callOptions = []): FetchGitAheadBehindResponse + { return $this->startApiCall('FetchGitAheadBehind', $request, $callOptions)->wait(); } @@ -1126,10 +1088,8 @@ public function fetchGitAheadBehind( * * @throws ApiException Thrown if the API call fails. */ - public function fetchRemoteBranches( - FetchRemoteBranchesRequest $request, - array $callOptions = [] - ): FetchRemoteBranchesResponse { + public function fetchRemoteBranches(FetchRemoteBranchesRequest $request, array $callOptions = []): FetchRemoteBranchesResponse + { return $this->startApiCall('FetchRemoteBranches', $request, $callOptions)->wait(); } @@ -1155,10 +1115,8 @@ public function fetchRemoteBranches( * * @throws ApiException Thrown if the API call fails. */ - public function fetchRepositoryHistory( - FetchRepositoryHistoryRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function fetchRepositoryHistory(FetchRepositoryHistoryRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('FetchRepositoryHistory', $request, $callOptions); } @@ -1183,10 +1141,8 @@ public function fetchRepositoryHistory( * * @throws ApiException Thrown if the API call fails. */ - public function getCompilationResult( - GetCompilationResultRequest $request, - array $callOptions = [] - ): CompilationResult { + public function getCompilationResult(GetCompilationResultRequest $request, array $callOptions = []): CompilationResult + { return $this->startApiCall('GetCompilationResult', $request, $callOptions)->wait(); } @@ -1315,10 +1271,8 @@ public function getWorkflowConfig(GetWorkflowConfigRequest $request, array $call * * @throws ApiException Thrown if the API call fails. */ - public function getWorkflowInvocation( - GetWorkflowInvocationRequest $request, - array $callOptions = [] - ): WorkflowInvocation { + public function getWorkflowInvocation(GetWorkflowInvocationRequest $request, array $callOptions = []): WorkflowInvocation + { return $this->startApiCall('GetWorkflowInvocation', $request, $callOptions)->wait(); } @@ -1369,10 +1323,8 @@ public function getWorkspace(GetWorkspaceRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function installNpmPackages( - InstallNpmPackagesRequest $request, - array $callOptions = [] - ): InstallNpmPackagesResponse { + public function installNpmPackages(InstallNpmPackagesRequest $request, array $callOptions = []): InstallNpmPackagesResponse + { return $this->startApiCall('InstallNpmPackages', $request, $callOptions)->wait(); } @@ -1397,10 +1349,8 @@ public function installNpmPackages( * * @throws ApiException Thrown if the API call fails. */ - public function listCompilationResults( - ListCompilationResultsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listCompilationResults(ListCompilationResultsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListCompilationResults', $request, $callOptions); } @@ -1506,10 +1456,8 @@ public function listWorkflowConfigs(ListWorkflowConfigsRequest $request, array $ * * @throws ApiException Thrown if the API call fails. */ - public function listWorkflowInvocations( - ListWorkflowInvocationsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listWorkflowInvocations(ListWorkflowInvocationsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListWorkflowInvocations', $request, $callOptions); } @@ -1692,10 +1640,8 @@ public function pushGitCommits(PushGitCommitsRequest $request, array $callOption * * @throws ApiException Thrown if the API call fails. */ - public function queryCompilationResultActions( - QueryCompilationResultActionsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function queryCompilationResultActions(QueryCompilationResultActionsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('QueryCompilationResultActions', $request, $callOptions); } @@ -1720,10 +1666,8 @@ public function queryCompilationResultActions( * * @throws ApiException Thrown if the API call fails. */ - public function queryDirectoryContents( - QueryDirectoryContentsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function queryDirectoryContents(QueryDirectoryContentsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('QueryDirectoryContents', $request, $callOptions); } @@ -1750,10 +1694,8 @@ public function queryDirectoryContents( * * @throws ApiException Thrown if the API call fails. */ - public function queryRepositoryDirectoryContents( - QueryRepositoryDirectoryContentsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function queryRepositoryDirectoryContents(QueryRepositoryDirectoryContentsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('QueryRepositoryDirectoryContents', $request, $callOptions); } @@ -1779,10 +1721,8 @@ public function queryRepositoryDirectoryContents( * * @throws ApiException Thrown if the API call fails. */ - public function queryWorkflowInvocationActions( - QueryWorkflowInvocationActionsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function queryWorkflowInvocationActions(QueryWorkflowInvocationActionsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('QueryWorkflowInvocationActions', $request, $callOptions); } @@ -1834,10 +1774,8 @@ public function readFile(ReadFileRequest $request, array $callOptions = []): Rea * * @throws ApiException Thrown if the API call fails. */ - public function readRepositoryFile( - ReadRepositoryFileRequest $request, - array $callOptions = [] - ): ReadRepositoryFileResponse { + public function readRepositoryFile(ReadRepositoryFileRequest $request, array $callOptions = []): ReadRepositoryFileResponse + { return $this->startApiCall('ReadRepositoryFile', $request, $callOptions)->wait(); } @@ -1914,10 +1852,8 @@ public function removeFile(RemoveFileRequest $request, array $callOptions = []): * * @throws ApiException Thrown if the API call fails. */ - public function resetWorkspaceChanges( - ResetWorkspaceChangesRequest $request, - array $callOptions = [] - ): ResetWorkspaceChangesResponse { + public function resetWorkspaceChanges(ResetWorkspaceChangesRequest $request, array $callOptions = []): ResetWorkspaceChangesResponse + { return $this->startApiCall('ResetWorkspaceChanges', $request, $callOptions)->wait(); } @@ -2233,10 +2169,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/Dataform/src/V1beta1/Client/DataformClient.php b/Dataform/src/V1beta1/Client/DataformClient.php index 76a7938bd600..81ccec30a81b 100644 --- a/Dataform/src/V1beta1/Client/DataformClient.php +++ b/Dataform/src/V1beta1/Client/DataformClient.php @@ -29,6 +29,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -263,12 +264,8 @@ private static function getClientDefaults() * * @experimental */ - public static function compilationResultName( - string $project, - string $location, - string $repository, - string $compilationResult - ): string { + public static function compilationResultName(string $project, string $location, string $repository, string $compilationResult): string + { return self::getPathTemplate('compilationResult')->render([ 'project' => $project, 'location' => $location, @@ -333,13 +330,8 @@ public static function cryptoKeyName(string $project, string $location, string $ * * @experimental */ - public static function cryptoKeyVersionName( - string $project, - string $location, - string $keyRing, - string $cryptoKey, - string $cryptoKeyVersion - ): string { + public static function cryptoKeyVersionName(string $project, string $location, string $keyRing, string $cryptoKey, string $cryptoKeyVersion): string + { return self::getPathTemplate('cryptoKeyVersion')->render([ 'project' => $project, 'location' => $location, @@ -380,11 +372,8 @@ public static function locationName(string $project, string $location): string * * @experimental */ - public static function notebookRuntimeTemplateName( - string $project, - string $location, - string $notebookRuntimeTemplate - ): string { + public static function notebookRuntimeTemplateName(string $project, string $location, string $notebookRuntimeTemplate): string + { return self::getPathTemplate('notebookRuntimeTemplate')->render([ 'project' => $project, 'location' => $location, @@ -405,12 +394,8 @@ public static function notebookRuntimeTemplateName( * * @experimental */ - public static function releaseConfigName( - string $project, - string $location, - string $repository, - string $releaseConfig - ): string { + public static function releaseConfigName(string $project, string $location, string $repository, string $releaseConfig): string + { return self::getPathTemplate('releaseConfig')->render([ 'project' => $project, 'location' => $location, @@ -474,12 +459,8 @@ public static function secretVersionName(string $project, string $secret, string * * @experimental */ - public static function workflowConfigName( - string $project, - string $location, - string $repository, - string $workflowConfig - ): string { + public static function workflowConfigName(string $project, string $location, string $repository, string $workflowConfig): string + { return self::getPathTemplate('workflowConfig')->render([ 'project' => $project, 'location' => $location, @@ -501,12 +482,8 @@ public static function workflowConfigName( * * @experimental */ - public static function workflowInvocationName( - string $project, - string $location, - string $repository, - string $workflowInvocation - ): string { + public static function workflowInvocationName(string $project, string $location, string $repository, string $workflowInvocation): string + { return self::getPathTemplate('workflowInvocation')->render([ 'project' => $project, 'location' => $location, @@ -528,12 +505,8 @@ public static function workflowInvocationName( * * @experimental */ - public static function workspaceName( - string $project, - string $location, - string $repository, - string $workspace - ): string { + public static function workspaceName(string $project, string $location, string $repository, string $workspace): string + { return self::getPathTemplate('workspace')->render([ 'project' => $project, 'location' => $location, @@ -582,25 +555,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dataform.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dataform\V1beta1\DataformClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new DataformClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -638,13 +614,15 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException * * @experimental */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -684,10 +662,8 @@ public function __call($method, $args) * * @experimental */ - public function cancelWorkflowInvocation( - CancelWorkflowInvocationRequest $request, - array $callOptions = [] - ): CancelWorkflowInvocationResponse { + public function cancelWorkflowInvocation(CancelWorkflowInvocationRequest $request, array $callOptions = []): CancelWorkflowInvocationResponse + { return $this->startApiCall('CancelWorkflowInvocation', $request, $callOptions)->wait(); } @@ -715,10 +691,8 @@ public function cancelWorkflowInvocation( * * @experimental */ - public function commitRepositoryChanges( - CommitRepositoryChangesRequest $request, - array $callOptions = [] - ): CommitRepositoryChangesResponse { + public function commitRepositoryChanges(CommitRepositoryChangesRequest $request, array $callOptions = []): CommitRepositoryChangesResponse + { return $this->startApiCall('CommitRepositoryChanges', $request, $callOptions)->wait(); } @@ -745,10 +719,8 @@ public function commitRepositoryChanges( * * @experimental */ - public function commitWorkspaceChanges( - CommitWorkspaceChangesRequest $request, - array $callOptions = [] - ): CommitWorkspaceChangesResponse { + public function commitWorkspaceChanges(CommitWorkspaceChangesRequest $request, array $callOptions = []): CommitWorkspaceChangesResponse + { return $this->startApiCall('CommitWorkspaceChanges', $request, $callOptions)->wait(); } @@ -776,10 +748,8 @@ public function commitWorkspaceChanges( * * @experimental */ - public function computeRepositoryAccessTokenStatus( - ComputeRepositoryAccessTokenStatusRequest $request, - array $callOptions = [] - ): ComputeRepositoryAccessTokenStatusResponse { + public function computeRepositoryAccessTokenStatus(ComputeRepositoryAccessTokenStatusRequest $request, array $callOptions = []): ComputeRepositoryAccessTokenStatusResponse + { return $this->startApiCall('ComputeRepositoryAccessTokenStatus', $request, $callOptions)->wait(); } @@ -806,10 +776,8 @@ public function computeRepositoryAccessTokenStatus( * * @experimental */ - public function createCompilationResult( - CreateCompilationResultRequest $request, - array $callOptions = [] - ): CompilationResult { + public function createCompilationResult(CreateCompilationResultRequest $request, array $callOptions = []): CompilationResult + { return $this->startApiCall('CreateCompilationResult', $request, $callOptions)->wait(); } @@ -920,10 +888,8 @@ public function createWorkflowConfig(CreateWorkflowConfigRequest $request, array * * @experimental */ - public function createWorkflowInvocation( - CreateWorkflowInvocationRequest $request, - array $callOptions = [] - ): WorkflowInvocation { + public function createWorkflowInvocation(CreateWorkflowInvocationRequest $request, array $callOptions = []): WorkflowInvocation + { return $this->startApiCall('CreateWorkflowInvocation', $request, $callOptions)->wait(); } @@ -1136,10 +1102,8 @@ public function fetchFileDiff(FetchFileDiffRequest $request, array $callOptions * * @experimental */ - public function fetchFileGitStatuses( - FetchFileGitStatusesRequest $request, - array $callOptions = [] - ): FetchFileGitStatusesResponse { + public function fetchFileGitStatuses(FetchFileGitStatusesRequest $request, array $callOptions = []): FetchFileGitStatusesResponse + { return $this->startApiCall('FetchFileGitStatuses', $request, $callOptions)->wait(); } @@ -1166,10 +1130,8 @@ public function fetchFileGitStatuses( * * @experimental */ - public function fetchGitAheadBehind( - FetchGitAheadBehindRequest $request, - array $callOptions = [] - ): FetchGitAheadBehindResponse { + public function fetchGitAheadBehind(FetchGitAheadBehindRequest $request, array $callOptions = []): FetchGitAheadBehindResponse + { return $this->startApiCall('FetchGitAheadBehind', $request, $callOptions)->wait(); } @@ -1196,10 +1158,8 @@ public function fetchGitAheadBehind( * * @experimental */ - public function fetchRemoteBranches( - FetchRemoteBranchesRequest $request, - array $callOptions = [] - ): FetchRemoteBranchesResponse { + public function fetchRemoteBranches(FetchRemoteBranchesRequest $request, array $callOptions = []): FetchRemoteBranchesResponse + { return $this->startApiCall('FetchRemoteBranches', $request, $callOptions)->wait(); } @@ -1227,10 +1187,8 @@ public function fetchRemoteBranches( * * @experimental */ - public function fetchRepositoryHistory( - FetchRepositoryHistoryRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function fetchRepositoryHistory(FetchRepositoryHistoryRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('FetchRepositoryHistory', $request, $callOptions); } @@ -1257,10 +1215,8 @@ public function fetchRepositoryHistory( * * @experimental */ - public function getCompilationResult( - GetCompilationResultRequest $request, - array $callOptions = [] - ): CompilationResult { + public function getCompilationResult(GetCompilationResultRequest $request, array $callOptions = []): CompilationResult + { return $this->startApiCall('GetCompilationResult', $request, $callOptions)->wait(); } @@ -1399,10 +1355,8 @@ public function getWorkflowConfig(GetWorkflowConfigRequest $request, array $call * * @experimental */ - public function getWorkflowInvocation( - GetWorkflowInvocationRequest $request, - array $callOptions = [] - ): WorkflowInvocation { + public function getWorkflowInvocation(GetWorkflowInvocationRequest $request, array $callOptions = []): WorkflowInvocation + { return $this->startApiCall('GetWorkflowInvocation', $request, $callOptions)->wait(); } @@ -1457,10 +1411,8 @@ public function getWorkspace(GetWorkspaceRequest $request, array $callOptions = * * @experimental */ - public function installNpmPackages( - InstallNpmPackagesRequest $request, - array $callOptions = [] - ): InstallNpmPackagesResponse { + public function installNpmPackages(InstallNpmPackagesRequest $request, array $callOptions = []): InstallNpmPackagesResponse + { return $this->startApiCall('InstallNpmPackages', $request, $callOptions)->wait(); } @@ -1487,10 +1439,8 @@ public function installNpmPackages( * * @experimental */ - public function listCompilationResults( - ListCompilationResultsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listCompilationResults(ListCompilationResultsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListCompilationResults', $request, $callOptions); } @@ -1604,10 +1554,8 @@ public function listWorkflowConfigs(ListWorkflowConfigsRequest $request, array $ * * @experimental */ - public function listWorkflowInvocations( - ListWorkflowInvocationsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listWorkflowInvocations(ListWorkflowInvocationsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListWorkflowInvocations', $request, $callOptions); } @@ -1804,10 +1752,8 @@ public function pushGitCommits(PushGitCommitsRequest $request, array $callOption * * @experimental */ - public function queryCompilationResultActions( - QueryCompilationResultActionsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function queryCompilationResultActions(QueryCompilationResultActionsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('QueryCompilationResultActions', $request, $callOptions); } @@ -1834,10 +1780,8 @@ public function queryCompilationResultActions( * * @experimental */ - public function queryDirectoryContents( - QueryDirectoryContentsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function queryDirectoryContents(QueryDirectoryContentsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('QueryDirectoryContents', $request, $callOptions); } @@ -1866,10 +1810,8 @@ public function queryDirectoryContents( * * @experimental */ - public function queryRepositoryDirectoryContents( - QueryRepositoryDirectoryContentsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function queryRepositoryDirectoryContents(QueryRepositoryDirectoryContentsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('QueryRepositoryDirectoryContents', $request, $callOptions); } @@ -1897,10 +1839,8 @@ public function queryRepositoryDirectoryContents( * * @experimental */ - public function queryWorkflowInvocationActions( - QueryWorkflowInvocationActionsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function queryWorkflowInvocationActions(QueryWorkflowInvocationActionsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('QueryWorkflowInvocationActions', $request, $callOptions); } @@ -1956,10 +1896,8 @@ public function readFile(ReadFileRequest $request, array $callOptions = []): Rea * * @experimental */ - public function readRepositoryFile( - ReadRepositoryFileRequest $request, - array $callOptions = [] - ): ReadRepositoryFileResponse { + public function readRepositoryFile(ReadRepositoryFileRequest $request, array $callOptions = []): ReadRepositoryFileResponse + { return $this->startApiCall('ReadRepositoryFile', $request, $callOptions)->wait(); } @@ -2042,10 +1980,8 @@ public function removeFile(RemoveFileRequest $request, array $callOptions = []): * * @experimental */ - public function resetWorkspaceChanges( - ResetWorkspaceChangesRequest $request, - array $callOptions = [] - ): ResetWorkspaceChangesResponse { + public function resetWorkspaceChanges(ResetWorkspaceChangesRequest $request, array $callOptions = []): ResetWorkspaceChangesResponse + { return $this->startApiCall('ResetWorkspaceChanges', $request, $callOptions)->wait(); } @@ -2383,10 +2319,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @experimental */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/Dataplex/src/V1/Client/BusinessGlossaryServiceClient.php b/Dataplex/src/V1/Client/BusinessGlossaryServiceClient.php index e9fce93ca527..ca620f0709ba 100644 --- a/Dataplex/src/V1/Client/BusinessGlossaryServiceClient.php +++ b/Dataplex/src/V1/Client/BusinessGlossaryServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -127,7 +128,9 @@ final class BusinessGlossaryServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -144,8 +147,7 @@ private static function getClientDefaults() ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => - __DIR__ . '/../resources/business_glossary_service_rest_client_config.php', + 'restClientConfigPath' => __DIR__ . '/../resources/business_glossary_service_rest_client_config.php', ], ], ]; @@ -174,9 +176,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -231,12 +231,8 @@ public static function glossaryName(string $project, string $location, string $g * * @return string The formatted glossary_category resource. */ - public static function glossaryCategoryName( - string $project, - string $location, - string $glossary, - string $glossaryCategory - ): string { + public static function glossaryCategoryName(string $project, string $location, string $glossary, string $glossaryCategory): string + { return self::getPathTemplate('glossaryCategory')->render([ 'project' => $project, 'location' => $location, @@ -256,12 +252,8 @@ public static function glossaryCategoryName( * * @return string The formatted glossary_term resource. */ - public static function glossaryTermName( - string $project, - string $location, - string $glossary, - string $glossaryTerm - ): string { + public static function glossaryTermName(string $project, string $location, string $glossary, string $glossaryTerm): string + { return self::getPathTemplate('glossaryTerm')->render([ 'project' => $project, 'location' => $location, @@ -317,25 +309,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dataplex.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dataplex\V1\BusinessGlossaryServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new BusinessGlossaryServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -373,11 +368,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -413,7 +410,7 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -444,10 +441,8 @@ public function createGlossary(CreateGlossaryRequest $request, array $callOption * * @throws ApiException Thrown if the API call fails. */ - public function createGlossaryCategory( - CreateGlossaryCategoryRequest $request, - array $callOptions = [] - ): GlossaryCategory { + public function createGlossaryCategory(CreateGlossaryCategoryRequest $request, array $callOptions = []): GlossaryCategory + { return $this->startApiCall('CreateGlossaryCategory', $request, $callOptions)->wait(); } @@ -497,7 +492,7 @@ public function createGlossaryTerm(CreateGlossaryTermRequest $request, array $ca * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -687,10 +682,8 @@ public function listGlossaries(ListGlossariesRequest $request, array $callOption * * @throws ApiException Thrown if the API call fails. */ - public function listGlossaryCategories( - ListGlossaryCategoriesRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listGlossaryCategories(ListGlossaryCategoriesRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListGlossaryCategories', $request, $callOptions); } @@ -739,7 +732,7 @@ public function listGlossaryTerms(ListGlossaryTermsRequest $request, array $call * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -770,10 +763,8 @@ public function updateGlossary(UpdateGlossaryRequest $request, array $callOption * * @throws ApiException Thrown if the API call fails. */ - public function updateGlossaryCategory( - UpdateGlossaryCategoryRequest $request, - array $callOptions = [] - ): GlossaryCategory { + public function updateGlossaryCategory(UpdateGlossaryCategoryRequest $request, array $callOptions = []): GlossaryCategory + { return $this->startApiCall('UpdateGlossaryCategory', $request, $callOptions)->wait(); } @@ -889,10 +880,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } diff --git a/Dataplex/src/V1/Client/CatalogServiceClient.php b/Dataplex/src/V1/Client/CatalogServiceClient.php index 8822214bca0f..f34e799f7cc2 100644 --- a/Dataplex/src/V1/Client/CatalogServiceClient.php +++ b/Dataplex/src/V1/Client/CatalogServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -157,7 +158,9 @@ final class CatalogServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -203,9 +206,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -300,12 +301,8 @@ public static function entryGroupName(string $project, string $location, string * * @return string The formatted entry_link resource. */ - public static function entryLinkName( - string $project, - string $location, - string $entryGroup, - string $entryLink - ): string { + public static function entryLinkName(string $project, string $location, string $entryGroup, string $entryLink): string + { return self::getPathTemplate('entryLink')->render([ 'project' => $project, 'location' => $location, @@ -438,25 +435,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dataplex.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dataplex\V1\CatalogServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new CatalogServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -494,11 +494,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -562,7 +564,7 @@ public function cancelMetadataJob(CancelMetadataJobRequest $request, array $call * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -614,7 +616,7 @@ public function createEntry(CreateEntryRequest $request, array $callOptions = [] * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -666,7 +668,7 @@ public function createEntryLink(CreateEntryLinkRequest $request, array $callOpti * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -693,7 +695,7 @@ public function createEntryType(CreateEntryTypeRequest $request, array $callOpti * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -719,7 +721,7 @@ public function createMetadataJob(CreateMetadataJobRequest $request, array $call * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -771,7 +773,7 @@ public function deleteEntry(DeleteEntryRequest $request, array $callOptions = [] * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -823,7 +825,7 @@ public function deleteEntryLink(DeleteEntryLinkRequest $request, array $callOpti * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1187,7 +1189,7 @@ public function searchEntries(SearchEntriesRequest $request, array $callOptions * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1239,7 +1241,7 @@ public function updateEntry(UpdateEntryRequest $request, array $callOptions = [] * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1265,7 +1267,7 @@ public function updateEntryGroup(UpdateEntryGroupRequest $request, array $callOp * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1358,10 +1360,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } diff --git a/Dataplex/src/V1/Client/CmekServiceClient.php b/Dataplex/src/V1/Client/CmekServiceClient.php index ed87745eaec5..1e241276c8d5 100644 --- a/Dataplex/src/V1/Client/CmekServiceClient.php +++ b/Dataplex/src/V1/Client/CmekServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -100,7 +101,9 @@ final class CmekServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -146,9 +149,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -183,11 +184,8 @@ private function createOperationsClient(array $options) * * @return string The formatted encryption_config resource. */ - public static function encryptionConfigName( - string $organization, - string $location, - string $encryptionConfig - ): string { + public static function encryptionConfigName(string $organization, string $location, string $encryptionConfig): string + { return self::getPathTemplate('encryptionConfig')->render([ 'organization' => $organization, 'location' => $location, @@ -240,25 +238,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dataplex.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dataplex\V1\CmekServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new CmekServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -296,11 +297,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -335,14 +338,12 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function createEncryptionConfig( - CreateEncryptionConfigRequest $request, - array $callOptions = [] - ): OperationResponse { + public function createEncryptionConfig(CreateEncryptionConfigRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('CreateEncryptionConfig', $request, $callOptions)->wait(); } @@ -363,14 +364,12 @@ public function createEncryptionConfig( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function deleteEncryptionConfig( - DeleteEncryptionConfigRequest $request, - array $callOptions = [] - ): OperationResponse { + public function deleteEncryptionConfig(DeleteEncryptionConfigRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('DeleteEncryptionConfig', $request, $callOptions)->wait(); } @@ -421,10 +420,8 @@ public function getEncryptionConfig(GetEncryptionConfigRequest $request, array $ * * @throws ApiException Thrown if the API call fails. */ - public function listEncryptionConfigs( - ListEncryptionConfigsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listEncryptionConfigs(ListEncryptionConfigsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListEncryptionConfigs', $request, $callOptions); } @@ -445,14 +442,12 @@ public function listEncryptionConfigs( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function updateEncryptionConfig( - UpdateEncryptionConfigRequest $request, - array $callOptions = [] - ): OperationResponse { + public function updateEncryptionConfig(UpdateEncryptionConfigRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('UpdateEncryptionConfig', $request, $callOptions)->wait(); } @@ -540,10 +535,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } diff --git a/Dataplex/src/V1/Client/ContentServiceClient.php b/Dataplex/src/V1/Client/ContentServiceClient.php index d7bb08db1c8e..60f0dad5e8cf 100644 --- a/Dataplex/src/V1/Client/ContentServiceClient.php +++ b/Dataplex/src/V1/Client/ContentServiceClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -98,7 +99,9 @@ final class ContentServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private static function getClientDefaults() { @@ -187,25 +190,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dataplex.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dataplex\V1\ContentServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new ContentServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -243,11 +249,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -457,10 +465,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } diff --git a/Dataplex/src/V1/Client/DataScanServiceClient.php b/Dataplex/src/V1/Client/DataScanServiceClient.php index c53ca87c16d8..2389bb0e6f53 100644 --- a/Dataplex/src/V1/Client/DataScanServiceClient.php +++ b/Dataplex/src/V1/Client/DataScanServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -113,7 +114,9 @@ final class DataScanServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -159,9 +162,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -274,13 +275,8 @@ public static function datasetName(string $project, string $dataset): string * * @return string The formatted entity resource. */ - public static function entityName( - string $project, - string $location, - string $lake, - string $zone, - string $entity - ): string { + public static function entityName(string $project, string $location, string $lake, string $zone, string $entity): string + { return self::getPathTemplate('entity')->render([ 'project' => $project, 'location' => $location, @@ -355,25 +351,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dataplex.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dataplex\V1\DataScanServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new DataScanServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -411,11 +410,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -450,7 +451,7 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -476,7 +477,7 @@ public function createDataScan(CreateDataScanRequest $request, array $callOption * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -510,10 +511,8 @@ public function deleteDataScan(DeleteDataScanRequest $request, array $callOption * * @throws ApiException Thrown if the API call fails. */ - public function generateDataQualityRules( - GenerateDataQualityRulesRequest $request, - array $callOptions = [] - ): GenerateDataQualityRulesResponse { + public function generateDataQualityRules(GenerateDataQualityRulesRequest $request, array $callOptions = []): GenerateDataQualityRulesResponse + { return $this->startApiCall('GenerateDataQualityRules', $request, $callOptions)->wait(); } @@ -664,7 +663,7 @@ public function runDataScan(RunDataScanRequest $request, array $callOptions = [] * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -757,10 +756,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } diff --git a/Dataplex/src/V1/Client/DataTaxonomyServiceClient.php b/Dataplex/src/V1/Client/DataTaxonomyServiceClient.php index 55517aaf2724..19243ee506df 100644 --- a/Dataplex/src/V1/Client/DataTaxonomyServiceClient.php +++ b/Dataplex/src/V1/Client/DataTaxonomyServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -125,7 +126,9 @@ final class DataTaxonomyServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -171,9 +174,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -209,12 +210,8 @@ private function createOperationsClient(array $options) * * @return string The formatted data_attribute resource. */ - public static function dataAttributeName( - string $project, - string $location, - string $dataTaxonomy, - string $dataAttributeId - ): string { + public static function dataAttributeName(string $project, string $location, string $dataTaxonomy, string $dataAttributeId): string + { return self::getPathTemplate('dataAttribute')->render([ 'project' => $project, 'location' => $location, @@ -233,11 +230,8 @@ public static function dataAttributeName( * * @return string The formatted data_attribute_binding resource. */ - public static function dataAttributeBindingName( - string $project, - string $location, - string $dataAttributeBindingId - ): string { + public static function dataAttributeBindingName(string $project, string $location, string $dataAttributeBindingId): string + { return self::getPathTemplate('dataAttributeBinding')->render([ 'project' => $project, 'location' => $location, @@ -311,25 +305,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dataplex.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dataplex\V1\DataTaxonomyServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new DataTaxonomyServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -367,11 +364,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -407,7 +406,7 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -436,16 +435,14 @@ public function createDataAttribute(CreateDataAttributeRequest $request, array $ * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * * @deprecated This method will be removed in the next major version update. */ - public function createDataAttributeBinding( - CreateDataAttributeBindingRequest $request, - array $callOptions = [] - ): OperationResponse { + public function createDataAttributeBinding(CreateDataAttributeBindingRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('CreateDataAttributeBinding', $request, $callOptions)->wait(); } @@ -467,7 +464,7 @@ public function createDataAttributeBinding( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -496,7 +493,7 @@ public function createDataTaxonomy(CreateDataTaxonomyRequest $request, array $ca * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -527,16 +524,14 @@ public function deleteDataAttribute(DeleteDataAttributeRequest $request, array $ * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * * @deprecated This method will be removed in the next major version update. */ - public function deleteDataAttributeBinding( - DeleteDataAttributeBindingRequest $request, - array $callOptions = [] - ): OperationResponse { + public function deleteDataAttributeBinding(DeleteDataAttributeBindingRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('DeleteDataAttributeBinding', $request, $callOptions)->wait(); } @@ -559,7 +554,7 @@ public function deleteDataAttributeBinding( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -622,10 +617,8 @@ public function getDataAttribute(GetDataAttributeRequest $request, array $callOp * * @deprecated This method will be removed in the next major version update. */ - public function getDataAttributeBinding( - GetDataAttributeBindingRequest $request, - array $callOptions = [] - ): DataAttributeBinding { + public function getDataAttributeBinding(GetDataAttributeBindingRequest $request, array $callOptions = []): DataAttributeBinding + { return $this->startApiCall('GetDataAttributeBinding', $request, $callOptions)->wait(); } @@ -681,10 +674,8 @@ public function getDataTaxonomy(GetDataTaxonomyRequest $request, array $callOpti * * @deprecated This method will be removed in the next major version update. */ - public function listDataAttributeBindings( - ListDataAttributeBindingsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listDataAttributeBindings(ListDataAttributeBindingsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListDataAttributeBindings', $request, $callOptions); } @@ -764,7 +755,7 @@ public function listDataTaxonomies(ListDataTaxonomiesRequest $request, array $ca * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -793,16 +784,14 @@ public function updateDataAttribute(UpdateDataAttributeRequest $request, array $ * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * * @deprecated This method will be removed in the next major version update. */ - public function updateDataAttributeBinding( - UpdateDataAttributeBindingRequest $request, - array $callOptions = [] - ): OperationResponse { + public function updateDataAttributeBinding(UpdateDataAttributeBindingRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('UpdateDataAttributeBinding', $request, $callOptions)->wait(); } @@ -824,7 +813,7 @@ public function updateDataAttributeBinding( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -920,10 +909,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } diff --git a/Dataplex/src/V1/Client/DataplexServiceClient.php b/Dataplex/src/V1/Client/DataplexServiceClient.php index ac22aa11588e..a25d83fa1283 100644 --- a/Dataplex/src/V1/Client/DataplexServiceClient.php +++ b/Dataplex/src/V1/Client/DataplexServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -166,7 +167,9 @@ final class DataplexServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -212,9 +215,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -251,13 +252,8 @@ private function createOperationsClient(array $options) * * @return string The formatted asset resource. */ - public static function assetName( - string $project, - string $location, - string $lake, - string $zone, - string $asset - ): string { + public static function assetName(string $project, string $location, string $lake, string $zone, string $asset): string + { return self::getPathTemplate('asset')->render([ 'project' => $project, 'location' => $location, @@ -422,25 +418,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dataplex.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dataplex\V1\DataplexServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new DataplexServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -478,11 +477,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -541,7 +542,7 @@ public function cancelJob(CancelJobRequest $request, array $callOptions = []): v * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -567,7 +568,7 @@ public function createAsset(CreateAssetRequest $request, array $callOptions = [] * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -593,7 +594,7 @@ public function createEnvironment(CreateEnvironmentRequest $request, array $call * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -619,7 +620,7 @@ public function createLake(CreateLakeRequest $request, array $callOptions = []): * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -645,7 +646,7 @@ public function createTask(CreateTaskRequest $request, array $callOptions = []): * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -672,7 +673,7 @@ public function createZone(CreateZoneRequest $request, array $callOptions = []): * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -699,7 +700,7 @@ public function deleteAsset(DeleteAssetRequest $request, array $callOptions = [] * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -726,7 +727,7 @@ public function deleteEnvironment(DeleteEnvironmentRequest $request, array $call * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -752,7 +753,7 @@ public function deleteLake(DeleteLakeRequest $request, array $callOptions = []): * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -779,7 +780,7 @@ public function deleteTask(DeleteTaskRequest $request, array $callOptions = []): * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1247,7 +1248,7 @@ public function runTask(RunTaskRequest $request, array $callOptions = []): RunTa * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1273,7 +1274,7 @@ public function updateAsset(UpdateAssetRequest $request, array $callOptions = [] * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1299,7 +1300,7 @@ public function updateEnvironment(UpdateEnvironmentRequest $request, array $call * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1325,7 +1326,7 @@ public function updateLake(UpdateLakeRequest $request, array $callOptions = []): * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1351,7 +1352,7 @@ public function updateTask(UpdateTaskRequest $request, array $callOptions = []): * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1444,10 +1445,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } diff --git a/Dataplex/src/V1/Client/MetadataServiceClient.php b/Dataplex/src/V1/Client/MetadataServiceClient.php index 1653f34e3619..aa543cbf9f91 100644 --- a/Dataplex/src/V1/Client/MetadataServiceClient.php +++ b/Dataplex/src/V1/Client/MetadataServiceClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -107,7 +108,9 @@ final class MetadataServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private static function getClientDefaults() { @@ -140,13 +143,8 @@ private static function getClientDefaults() * * @return string The formatted entity resource. */ - public static function entityName( - string $project, - string $location, - string $lake, - string $zone, - string $entity - ): string { + public static function entityName(string $project, string $location, string $lake, string $zone, string $entity): string + { return self::getPathTemplate('entity')->render([ 'project' => $project, 'location' => $location, @@ -169,14 +167,8 @@ public static function entityName( * * @return string The formatted partition resource. */ - public static function partitionName( - string $project, - string $location, - string $lake, - string $zone, - string $entity, - string $partition - ): string { + public static function partitionName(string $project, string $location, string $lake, string $zone, string $entity, string $partition): string + { return self::getPathTemplate('partition')->render([ 'project' => $project, 'location' => $location, @@ -237,25 +229,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dataplex.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dataplex\V1\MetadataServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new MetadataServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -293,11 +288,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -628,10 +625,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } diff --git a/Dataproc/src/V1/Client/AutoscalingPolicyServiceClient.php b/Dataproc/src/V1/Client/AutoscalingPolicyServiceClient.php index c504a61bcead..bf994e1dd78b 100644 --- a/Dataproc/src/V1/Client/AutoscalingPolicyServiceClient.php +++ b/Dataproc/src/V1/Client/AutoscalingPolicyServiceClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -93,7 +94,9 @@ final class AutoscalingPolicyServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private static function getClientDefaults() { @@ -108,8 +111,7 @@ private static function getClientDefaults() ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => - __DIR__ . '/../resources/autoscaling_policy_service_rest_client_config.php', + 'restClientConfigPath' => __DIR__ . '/../resources/autoscaling_policy_service_rest_client_config.php', ], ], ]; @@ -161,11 +163,8 @@ public static function locationName(string $project, string $location): string * * @return string The formatted project_location_autoscaling_policy resource. */ - public static function projectLocationAutoscalingPolicyName( - string $project, - string $location, - string $autoscalingPolicy - ): string { + public static function projectLocationAutoscalingPolicyName(string $project, string $location, string $autoscalingPolicy): string + { return self::getPathTemplate('projectLocationAutoscalingPolicy')->render([ 'project' => $project, 'location' => $location, @@ -183,11 +182,8 @@ public static function projectLocationAutoscalingPolicyName( * * @return string The formatted project_region_autoscaling_policy resource. */ - public static function projectRegionAutoscalingPolicyName( - string $project, - string $region, - string $autoscalingPolicy - ): string { + public static function projectRegionAutoscalingPolicyName(string $project, string $region, string $autoscalingPolicy): string + { return self::getPathTemplate('projectRegionAutoscalingPolicy')->render([ 'project' => $project, 'region' => $region, @@ -243,25 +239,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dataproc.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dataproc\V1\AutoscalingPolicyServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new AutoscalingPolicyServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -299,11 +298,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -342,10 +343,8 @@ public function __call($method, $args) * * @throws ApiException Thrown if the API call fails. */ - public function createAutoscalingPolicy( - CreateAutoscalingPolicyRequest $request, - array $callOptions = [] - ): AutoscalingPolicy { + public function createAutoscalingPolicy(CreateAutoscalingPolicyRequest $request, array $callOptions = []): AutoscalingPolicy + { return $this->startApiCall('CreateAutoscalingPolicy', $request, $callOptions)->wait(); } @@ -397,10 +396,8 @@ public function deleteAutoscalingPolicy(DeleteAutoscalingPolicyRequest $request, * * @throws ApiException Thrown if the API call fails. */ - public function getAutoscalingPolicy( - GetAutoscalingPolicyRequest $request, - array $callOptions = [] - ): AutoscalingPolicy { + public function getAutoscalingPolicy(GetAutoscalingPolicyRequest $request, array $callOptions = []): AutoscalingPolicy + { return $this->startApiCall('GetAutoscalingPolicy', $request, $callOptions)->wait(); } @@ -426,10 +423,8 @@ public function getAutoscalingPolicy( * * @throws ApiException Thrown if the API call fails. */ - public function listAutoscalingPolicies( - ListAutoscalingPoliciesRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listAutoscalingPolicies(ListAutoscalingPoliciesRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListAutoscalingPolicies', $request, $callOptions); } @@ -458,10 +453,8 @@ public function listAutoscalingPolicies( * * @throws ApiException Thrown if the API call fails. */ - public function updateAutoscalingPolicy( - UpdateAutoscalingPolicyRequest $request, - array $callOptions = [] - ): AutoscalingPolicy { + public function updateAutoscalingPolicy(UpdateAutoscalingPolicyRequest $request, array $callOptions = []): AutoscalingPolicy + { return $this->startApiCall('UpdateAutoscalingPolicy', $request, $callOptions)->wait(); } @@ -552,10 +545,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/Dataproc/src/V1/Client/BatchControllerClient.php b/Dataproc/src/V1/Client/BatchControllerClient.php index c3345c401293..cda55609b2c3 100644 --- a/Dataproc/src/V1/Client/BatchControllerClient.php +++ b/Dataproc/src/V1/Client/BatchControllerClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -93,7 +94,9 @@ final class BatchControllerClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -139,9 +142,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -250,25 +251,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dataproc.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dataproc\V1\BatchControllerClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new BatchControllerClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -306,11 +310,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -345,7 +351,7 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -515,10 +521,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/Dataproc/src/V1/Client/ClusterControllerClient.php b/Dataproc/src/V1/Client/ClusterControllerClient.php index ed69d4550221..8ce3fae5d1be 100644 --- a/Dataproc/src/V1/Client/ClusterControllerClient.php +++ b/Dataproc/src/V1/Client/ClusterControllerClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -104,7 +105,9 @@ final class ClusterControllerClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -150,9 +153,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -307,25 +308,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dataproc.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dataproc\V1\ClusterControllerClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new ClusterControllerClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -363,11 +367,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -404,7 +410,7 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -432,7 +438,7 @@ public function createCluster(CreateClusterRequest $request, array $callOptions * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -464,7 +470,7 @@ public function deleteCluster(DeleteClusterRequest $request, array $callOptions * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -542,7 +548,7 @@ public function listClusters(ListClustersRequest $request, array $callOptions = * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -568,7 +574,7 @@ public function startCluster(StartClusterRequest $request, array $callOptions = * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -599,7 +605,7 @@ public function stopCluster(StopClusterRequest $request, array $callOptions = [] * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -692,10 +698,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/Dataproc/src/V1/Client/JobControllerClient.php b/Dataproc/src/V1/Client/JobControllerClient.php index 6d71bed44e4c..aa015a5988ad 100644 --- a/Dataproc/src/V1/Client/JobControllerClient.php +++ b/Dataproc/src/V1/Client/JobControllerClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; @@ -91,7 +92,9 @@ final class JobControllerClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -137,9 +140,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -167,25 +168,28 @@ private function createOperationsClient(array $options) /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dataproc.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dataproc\V1\JobControllerClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new JobControllerClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -223,11 +227,13 @@ private function createOperationsClient(array $options) * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -395,7 +401,7 @@ public function submitJob(SubmitJobRequest $request, array $callOptions = []): J * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -514,10 +520,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/Dataproc/src/V1/Client/NodeGroupControllerClient.php b/Dataproc/src/V1/Client/NodeGroupControllerClient.php index bb34c22861f6..c8685c45e960 100644 --- a/Dataproc/src/V1/Client/NodeGroupControllerClient.php +++ b/Dataproc/src/V1/Client/NodeGroupControllerClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; @@ -92,7 +93,9 @@ final class NodeGroupControllerClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -138,9 +141,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -233,25 +234,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dataproc.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dataproc\V1\NodeGroupControllerClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new NodeGroupControllerClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -289,11 +293,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -330,7 +336,7 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -385,7 +391,7 @@ public function getNodeGroup(GetNodeGroupRequest $request, array $callOptions = * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -479,10 +485,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/Dataproc/src/V1/Client/SessionControllerClient.php b/Dataproc/src/V1/Client/SessionControllerClient.php index f39debcd1396..00c5e004d43c 100644 --- a/Dataproc/src/V1/Client/SessionControllerClient.php +++ b/Dataproc/src/V1/Client/SessionControllerClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -95,7 +96,9 @@ final class SessionControllerClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -141,9 +144,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -272,25 +273,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dataproc.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dataproc\V1\SessionControllerClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new SessionControllerClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -328,11 +332,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -367,7 +373,7 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -394,7 +400,7 @@ public function createSession(CreateSessionRequest $request, array $callOptions * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -472,7 +478,7 @@ public function listSessions(ListSessionsRequest $request, array $callOptions = * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -565,10 +571,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/Dataproc/src/V1/Client/SessionTemplateControllerClient.php b/Dataproc/src/V1/Client/SessionTemplateControllerClient.php index de3f4088bae9..023b44def9c6 100644 --- a/Dataproc/src/V1/Client/SessionTemplateControllerClient.php +++ b/Dataproc/src/V1/Client/SessionTemplateControllerClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -92,7 +93,9 @@ final class SessionTemplateControllerClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private static function getClientDefaults() { @@ -107,8 +110,7 @@ private static function getClientDefaults() ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => - __DIR__ . '/../resources/session_template_controller_rest_client_config.php', + 'restClientConfigPath' => __DIR__ . '/../resources/session_template_controller_rest_client_config.php', ], ], ]; @@ -198,25 +200,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dataproc.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dataproc\V1\SessionTemplateControllerClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new SessionTemplateControllerClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -254,11 +259,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -297,10 +304,8 @@ public function __call($method, $args) * * @throws ApiException Thrown if the API call fails. */ - public function createSessionTemplate( - CreateSessionTemplateRequest $request, - array $callOptions = [] - ): SessionTemplate { + public function createSessionTemplate(CreateSessionTemplateRequest $request, array $callOptions = []): SessionTemplate + { return $this->startApiCall('CreateSessionTemplate', $request, $callOptions)->wait(); } @@ -378,10 +383,8 @@ public function getSessionTemplate(GetSessionTemplateRequest $request, array $ca * * @throws ApiException Thrown if the API call fails. */ - public function listSessionTemplates( - ListSessionTemplatesRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listSessionTemplates(ListSessionTemplatesRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListSessionTemplates', $request, $callOptions); } @@ -407,10 +410,8 @@ public function listSessionTemplates( * * @throws ApiException Thrown if the API call fails. */ - public function updateSessionTemplate( - UpdateSessionTemplateRequest $request, - array $callOptions = [] - ): SessionTemplate { + public function updateSessionTemplate(UpdateSessionTemplateRequest $request, array $callOptions = []): SessionTemplate + { return $this->startApiCall('UpdateSessionTemplate', $request, $callOptions)->wait(); } @@ -501,10 +502,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/Dataproc/src/V1/Client/WorkflowTemplateServiceClient.php b/Dataproc/src/V1/Client/WorkflowTemplateServiceClient.php index bb8da73a3b6e..359fc57122e3 100644 --- a/Dataproc/src/V1/Client/WorkflowTemplateServiceClient.php +++ b/Dataproc/src/V1/Client/WorkflowTemplateServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -101,7 +102,9 @@ final class WorkflowTemplateServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -118,8 +121,7 @@ private static function getClientDefaults() ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => - __DIR__ . '/../resources/workflow_template_service_rest_client_config.php', + 'restClientConfigPath' => __DIR__ . '/../resources/workflow_template_service_rest_client_config.php', ], ], ]; @@ -148,9 +150,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -263,11 +263,8 @@ public static function nodeGroupName(string $project, string $region, string $cl * * @return string The formatted project_location_workflow_template resource. */ - public static function projectLocationWorkflowTemplateName( - string $project, - string $location, - string $workflowTemplate - ): string { + public static function projectLocationWorkflowTemplateName(string $project, string $location, string $workflowTemplate): string + { return self::getPathTemplate('projectLocationWorkflowTemplate')->render([ 'project' => $project, 'location' => $location, @@ -285,11 +282,8 @@ public static function projectLocationWorkflowTemplateName( * * @return string The formatted project_region_workflow_template resource. */ - public static function projectRegionWorkflowTemplateName( - string $project, - string $region, - string $workflowTemplate - ): string { + public static function projectRegionWorkflowTemplateName(string $project, string $region, string $workflowTemplate): string + { return self::getPathTemplate('projectRegionWorkflowTemplate')->render([ 'project' => $project, 'region' => $region, @@ -387,25 +381,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dataproc.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dataproc\V1\WorkflowTemplateServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new WorkflowTemplateServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -443,11 +440,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -487,10 +486,8 @@ public function __call($method, $args) * * @throws ApiException Thrown if the API call fails. */ - public function createWorkflowTemplate( - CreateWorkflowTemplateRequest $request, - array $callOptions = [] - ): WorkflowTemplate { + public function createWorkflowTemplate(CreateWorkflowTemplateRequest $request, array $callOptions = []): WorkflowTemplate + { return $this->startApiCall('CreateWorkflowTemplate', $request, $callOptions)->wait(); } @@ -591,14 +588,12 @@ public function getWorkflowTemplate(GetWorkflowTemplateRequest $request, array $ * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function instantiateInlineWorkflowTemplate( - InstantiateInlineWorkflowTemplateRequest $request, - array $callOptions = [] - ): OperationResponse { + public function instantiateInlineWorkflowTemplate(InstantiateInlineWorkflowTemplateRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('InstantiateInlineWorkflowTemplate', $request, $callOptions)->wait(); } @@ -639,14 +634,12 @@ public function instantiateInlineWorkflowTemplate( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function instantiateWorkflowTemplate( - InstantiateWorkflowTemplateRequest $request, - array $callOptions = [] - ): OperationResponse { + public function instantiateWorkflowTemplate(InstantiateWorkflowTemplateRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('InstantiateWorkflowTemplate', $request, $callOptions)->wait(); } @@ -672,10 +665,8 @@ public function instantiateWorkflowTemplate( * * @throws ApiException Thrown if the API call fails. */ - public function listWorkflowTemplates( - ListWorkflowTemplatesRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listWorkflowTemplates(ListWorkflowTemplatesRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListWorkflowTemplates', $request, $callOptions); } @@ -702,10 +693,8 @@ public function listWorkflowTemplates( * * @throws ApiException Thrown if the API call fails. */ - public function updateWorkflowTemplate( - UpdateWorkflowTemplateRequest $request, - array $callOptions = [] - ): WorkflowTemplate { + public function updateWorkflowTemplate(UpdateWorkflowTemplateRequest $request, array $callOptions = []): WorkflowTemplate + { return $this->startApiCall('UpdateWorkflowTemplate', $request, $callOptions)->wait(); } @@ -794,10 +783,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/DataprocMetastore/src/V1/Client/DataprocMetastoreClient.php b/DataprocMetastore/src/V1/Client/DataprocMetastoreClient.php index 5069c088c20b..c8a6843f3645 100644 --- a/DataprocMetastore/src/V1/Client/DataprocMetastoreClient.php +++ b/DataprocMetastore/src/V1/Client/DataprocMetastoreClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -43,6 +44,7 @@ use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; use Google\Cloud\Metastore\V1\AlterMetadataResourceLocationRequest; +use Google\Cloud\Metastore\V1\AlterMetadataResourceLocationResponse; use Google\Cloud\Metastore\V1\Backup; use Google\Cloud\Metastore\V1\CreateBackupRequest; use Google\Cloud\Metastore\V1\CreateMetadataImportRequest; @@ -56,9 +58,13 @@ use Google\Cloud\Metastore\V1\ListBackupsRequest; use Google\Cloud\Metastore\V1\ListMetadataImportsRequest; use Google\Cloud\Metastore\V1\ListServicesRequest; +use Google\Cloud\Metastore\V1\MetadataExport; use Google\Cloud\Metastore\V1\MetadataImport; use Google\Cloud\Metastore\V1\MoveTableToDatabaseRequest; +use Google\Cloud\Metastore\V1\MoveTableToDatabaseResponse; use Google\Cloud\Metastore\V1\QueryMetadataRequest; +use Google\Cloud\Metastore\V1\QueryMetadataResponse; +use Google\Cloud\Metastore\V1\Restore; use Google\Cloud\Metastore\V1\RestoreServiceRequest; use Google\Cloud\Metastore\V1\Service; use Google\Cloud\Metastore\V1\UpdateMetadataImportRequest; @@ -144,7 +150,9 @@ final class DataprocMetastoreClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -190,9 +198,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -266,12 +272,8 @@ public static function locationName(string $project, string $location): string * * @return string The formatted metadata_import resource. */ - public static function metadataImportName( - string $project, - string $location, - string $service, - string $metadataImport - ): string { + public static function metadataImportName(string $project, string $location, string $service, string $metadataImport): string + { return self::getPathTemplate('metadataImport')->render([ 'project' => $project, 'location' => $location, @@ -367,25 +369,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'metastore.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Metastore\V1\DataprocMetastoreClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new DataprocMetastoreClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -423,11 +428,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -466,14 +473,12 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function alterMetadataResourceLocation( - AlterMetadataResourceLocationRequest $request, - array $callOptions = [] - ): OperationResponse { + public function alterMetadataResourceLocation(AlterMetadataResourceLocationRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('AlterMetadataResourceLocation', $request, $callOptions)->wait(); } @@ -494,7 +499,7 @@ public function alterMetadataResourceLocation( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -521,14 +526,12 @@ public function createBackup(CreateBackupRequest $request, array $callOptions = * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function createMetadataImport( - CreateMetadataImportRequest $request, - array $callOptions = [] - ): OperationResponse { + public function createMetadataImport(CreateMetadataImportRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('CreateMetadataImport', $request, $callOptions)->wait(); } @@ -549,7 +552,7 @@ public function createMetadataImport( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -575,7 +578,7 @@ public function createService(CreateServiceRequest $request, array $callOptions * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -601,7 +604,7 @@ public function deleteBackup(DeleteBackupRequest $request, array $callOptions = * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -627,7 +630,7 @@ public function deleteService(DeleteServiceRequest $request, array $callOptions * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -811,7 +814,7 @@ public function listServices(ListServicesRequest $request, array $callOptions = * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -837,7 +840,7 @@ public function moveTableToDatabase(MoveTableToDatabaseRequest $request, array $ * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -863,7 +866,7 @@ public function queryMetadata(QueryMetadataRequest $request, array $callOptions * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -891,14 +894,12 @@ public function restoreService(RestoreServiceRequest $request, array $callOption * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function updateMetadataImport( - UpdateMetadataImportRequest $request, - array $callOptions = [] - ): OperationResponse { + public function updateMetadataImport(UpdateMetadataImportRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('UpdateMetadataImport', $request, $callOptions)->wait(); } @@ -919,7 +920,7 @@ public function updateMetadataImport( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1064,10 +1065,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/DataprocMetastore/src/V1/Client/DataprocMetastoreFederationClient.php b/DataprocMetastore/src/V1/Client/DataprocMetastoreFederationClient.php index 70219bf9b54c..9af8e0a396f0 100644 --- a/DataprocMetastore/src/V1/Client/DataprocMetastoreFederationClient.php +++ b/DataprocMetastore/src/V1/Client/DataprocMetastoreFederationClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -112,7 +113,9 @@ final class DataprocMetastoreFederationClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -129,8 +132,7 @@ private static function getClientDefaults() ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => - __DIR__ . '/../resources/dataproc_metastore_federation_rest_client_config.php', + 'restClientConfigPath' => __DIR__ . '/../resources/dataproc_metastore_federation_rest_client_config.php', ], ], ]; @@ -159,9 +161,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -250,25 +250,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'metastore.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Metastore\V1\DataprocMetastoreFederationClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new DataprocMetastoreFederationClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -306,11 +309,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -346,7 +351,7 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -373,7 +378,7 @@ public function createFederation(CreateFederationRequest $request, array $callOp * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -454,7 +459,7 @@ public function listFederations(ListFederationsRequest $request, array $callOpti * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -604,10 +609,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/DataprocMetastore/src/V1alpha/Client/DataprocMetastoreClient.php b/DataprocMetastore/src/V1alpha/Client/DataprocMetastoreClient.php index a849adf9503e..1e914f998111 100644 --- a/DataprocMetastore/src/V1alpha/Client/DataprocMetastoreClient.php +++ b/DataprocMetastore/src/V1alpha/Client/DataprocMetastoreClient.php @@ -30,6 +30,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -45,6 +46,7 @@ use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; use Google\Cloud\Metastore\V1alpha\AlterMetadataResourceLocationRequest; +use Google\Cloud\Metastore\V1alpha\AlterMetadataResourceLocationResponse; use Google\Cloud\Metastore\V1alpha\Backup; use Google\Cloud\Metastore\V1alpha\CreateBackupRequest; use Google\Cloud\Metastore\V1alpha\CreateMetadataImportRequest; @@ -58,11 +60,15 @@ use Google\Cloud\Metastore\V1alpha\ListBackupsRequest; use Google\Cloud\Metastore\V1alpha\ListMetadataImportsRequest; use Google\Cloud\Metastore\V1alpha\ListServicesRequest; +use Google\Cloud\Metastore\V1alpha\MetadataExport; use Google\Cloud\Metastore\V1alpha\MetadataImport; use Google\Cloud\Metastore\V1alpha\MoveTableToDatabaseRequest; +use Google\Cloud\Metastore\V1alpha\MoveTableToDatabaseResponse; use Google\Cloud\Metastore\V1alpha\QueryMetadataRequest; +use Google\Cloud\Metastore\V1alpha\QueryMetadataResponse; use Google\Cloud\Metastore\V1alpha\RemoveIamPolicyRequest; use Google\Cloud\Metastore\V1alpha\RemoveIamPolicyResponse; +use Google\Cloud\Metastore\V1alpha\Restore; use Google\Cloud\Metastore\V1alpha\RestoreServiceRequest; use Google\Cloud\Metastore\V1alpha\Service; use Google\Cloud\Metastore\V1alpha\UpdateMetadataImportRequest; @@ -151,7 +157,9 @@ final class DataprocMetastoreClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -201,9 +209,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -304,12 +310,8 @@ public static function locationName(string $project, string $location): string * * @experimental */ - public static function metadataImportName( - string $project, - string $location, - string $service, - string $metadataImport - ): string { + public static function metadataImportName(string $project, string $location, string $service, string $metadataImport): string + { return self::getPathTemplate('metadataImport')->render([ 'project' => $project, 'location' => $location, @@ -414,25 +416,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'metastore.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Metastore\V1alpha\DataprocMetastoreClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new DataprocMetastoreClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -470,13 +475,15 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException * * @experimental */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -515,16 +522,14 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * * @experimental */ - public function alterMetadataResourceLocation( - AlterMetadataResourceLocationRequest $request, - array $callOptions = [] - ): OperationResponse { + public function alterMetadataResourceLocation(AlterMetadataResourceLocationRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('AlterMetadataResourceLocation', $request, $callOptions)->wait(); } @@ -545,7 +550,7 @@ public function alterMetadataResourceLocation( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -574,16 +579,14 @@ public function createBackup(CreateBackupRequest $request, array $callOptions = * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * * @experimental */ - public function createMetadataImport( - CreateMetadataImportRequest $request, - array $callOptions = [] - ): OperationResponse { + public function createMetadataImport(CreateMetadataImportRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('CreateMetadataImport', $request, $callOptions)->wait(); } @@ -604,7 +607,7 @@ public function createMetadataImport( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -632,7 +635,7 @@ public function createService(CreateServiceRequest $request, array $callOptions * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -660,7 +663,7 @@ public function deleteBackup(DeleteBackupRequest $request, array $callOptions = * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -688,7 +691,7 @@ public function deleteService(DeleteServiceRequest $request, array $callOptions * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -886,7 +889,7 @@ public function listServices(ListServicesRequest $request, array $callOptions = * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -914,7 +917,7 @@ public function moveTableToDatabase(MoveTableToDatabaseRequest $request, array $ * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -970,7 +973,7 @@ public function removeIamPolicy(RemoveIamPolicyRequest $request, array $callOpti * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -1000,16 +1003,14 @@ public function restoreService(RestoreServiceRequest $request, array $callOption * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * * @experimental */ - public function updateMetadataImport( - UpdateMetadataImportRequest $request, - array $callOptions = [] - ): OperationResponse { + public function updateMetadataImport(UpdateMetadataImportRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('UpdateMetadataImport', $request, $callOptions)->wait(); } @@ -1030,7 +1031,7 @@ public function updateMetadataImport( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -1187,10 +1188,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @experimental */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/DataprocMetastore/src/V1alpha/Client/DataprocMetastoreFederationClient.php b/DataprocMetastore/src/V1alpha/Client/DataprocMetastoreFederationClient.php index ee801b5d9806..30dd75493403 100644 --- a/DataprocMetastore/src/V1alpha/Client/DataprocMetastoreFederationClient.php +++ b/DataprocMetastore/src/V1alpha/Client/DataprocMetastoreFederationClient.php @@ -30,6 +30,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -116,7 +117,9 @@ final class DataprocMetastoreFederationClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -133,8 +136,7 @@ private static function getClientDefaults() ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => - __DIR__ . '/../resources/dataproc_metastore_federation_rest_client_config.php', + 'restClientConfigPath' => __DIR__ . '/../resources/dataproc_metastore_federation_rest_client_config.php', ], ], ]; @@ -167,9 +169,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -264,25 +264,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'metastore.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Metastore\V1alpha\DataprocMetastoreFederationClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new DataprocMetastoreFederationClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -320,13 +323,15 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException * * @experimental */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -362,7 +367,7 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -391,7 +396,7 @@ public function createFederation(CreateFederationRequest $request, array $callOp * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -478,7 +483,7 @@ public function listFederations(ListFederationsRequest $request, array $callOpti * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -640,10 +645,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @experimental */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/DataprocMetastore/src/V1beta/Client/DataprocMetastoreClient.php b/DataprocMetastore/src/V1beta/Client/DataprocMetastoreClient.php index 54f575d2ffca..101e266e5575 100644 --- a/DataprocMetastore/src/V1beta/Client/DataprocMetastoreClient.php +++ b/DataprocMetastore/src/V1beta/Client/DataprocMetastoreClient.php @@ -30,6 +30,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -45,6 +46,7 @@ use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; use Google\Cloud\Metastore\V1beta\AlterMetadataResourceLocationRequest; +use Google\Cloud\Metastore\V1beta\AlterMetadataResourceLocationResponse; use Google\Cloud\Metastore\V1beta\Backup; use Google\Cloud\Metastore\V1beta\CreateBackupRequest; use Google\Cloud\Metastore\V1beta\CreateMetadataImportRequest; @@ -58,11 +60,15 @@ use Google\Cloud\Metastore\V1beta\ListBackupsRequest; use Google\Cloud\Metastore\V1beta\ListMetadataImportsRequest; use Google\Cloud\Metastore\V1beta\ListServicesRequest; +use Google\Cloud\Metastore\V1beta\MetadataExport; use Google\Cloud\Metastore\V1beta\MetadataImport; use Google\Cloud\Metastore\V1beta\MoveTableToDatabaseRequest; +use Google\Cloud\Metastore\V1beta\MoveTableToDatabaseResponse; use Google\Cloud\Metastore\V1beta\QueryMetadataRequest; +use Google\Cloud\Metastore\V1beta\QueryMetadataResponse; use Google\Cloud\Metastore\V1beta\RemoveIamPolicyRequest; use Google\Cloud\Metastore\V1beta\RemoveIamPolicyResponse; +use Google\Cloud\Metastore\V1beta\Restore; use Google\Cloud\Metastore\V1beta\RestoreServiceRequest; use Google\Cloud\Metastore\V1beta\Service; use Google\Cloud\Metastore\V1beta\UpdateMetadataImportRequest; @@ -151,7 +157,9 @@ final class DataprocMetastoreClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -201,9 +209,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -304,12 +310,8 @@ public static function locationName(string $project, string $location): string * * @experimental */ - public static function metadataImportName( - string $project, - string $location, - string $service, - string $metadataImport - ): string { + public static function metadataImportName(string $project, string $location, string $service, string $metadataImport): string + { return self::getPathTemplate('metadataImport')->render([ 'project' => $project, 'location' => $location, @@ -414,25 +416,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'metastore.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Metastore\V1beta\DataprocMetastoreClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new DataprocMetastoreClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -470,13 +475,15 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException * * @experimental */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -515,16 +522,14 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * * @experimental */ - public function alterMetadataResourceLocation( - AlterMetadataResourceLocationRequest $request, - array $callOptions = [] - ): OperationResponse { + public function alterMetadataResourceLocation(AlterMetadataResourceLocationRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('AlterMetadataResourceLocation', $request, $callOptions)->wait(); } @@ -545,7 +550,7 @@ public function alterMetadataResourceLocation( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -574,16 +579,14 @@ public function createBackup(CreateBackupRequest $request, array $callOptions = * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * * @experimental */ - public function createMetadataImport( - CreateMetadataImportRequest $request, - array $callOptions = [] - ): OperationResponse { + public function createMetadataImport(CreateMetadataImportRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('CreateMetadataImport', $request, $callOptions)->wait(); } @@ -604,7 +607,7 @@ public function createMetadataImport( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -632,7 +635,7 @@ public function createService(CreateServiceRequest $request, array $callOptions * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -660,7 +663,7 @@ public function deleteBackup(DeleteBackupRequest $request, array $callOptions = * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -688,7 +691,7 @@ public function deleteService(DeleteServiceRequest $request, array $callOptions * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -886,7 +889,7 @@ public function listServices(ListServicesRequest $request, array $callOptions = * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -914,7 +917,7 @@ public function moveTableToDatabase(MoveTableToDatabaseRequest $request, array $ * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -970,7 +973,7 @@ public function removeIamPolicy(RemoveIamPolicyRequest $request, array $callOpti * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -1000,16 +1003,14 @@ public function restoreService(RestoreServiceRequest $request, array $callOption * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * * @experimental */ - public function updateMetadataImport( - UpdateMetadataImportRequest $request, - array $callOptions = [] - ): OperationResponse { + public function updateMetadataImport(UpdateMetadataImportRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('UpdateMetadataImport', $request, $callOptions)->wait(); } @@ -1030,7 +1031,7 @@ public function updateMetadataImport( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -1187,10 +1188,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @experimental */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/DataprocMetastore/src/V1beta/Client/DataprocMetastoreFederationClient.php b/DataprocMetastore/src/V1beta/Client/DataprocMetastoreFederationClient.php index ac90d78b47d2..43e0bdcedd27 100644 --- a/DataprocMetastore/src/V1beta/Client/DataprocMetastoreFederationClient.php +++ b/DataprocMetastore/src/V1beta/Client/DataprocMetastoreFederationClient.php @@ -30,6 +30,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -116,7 +117,9 @@ final class DataprocMetastoreFederationClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -133,8 +136,7 @@ private static function getClientDefaults() ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => - __DIR__ . '/../resources/dataproc_metastore_federation_rest_client_config.php', + 'restClientConfigPath' => __DIR__ . '/../resources/dataproc_metastore_federation_rest_client_config.php', ], ], ]; @@ -167,9 +169,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -264,25 +264,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'metastore.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Metastore\V1beta\DataprocMetastoreFederationClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new DataprocMetastoreFederationClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -320,13 +323,15 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException * * @experimental */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -362,7 +367,7 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -391,7 +396,7 @@ public function createFederation(CreateFederationRequest $request, array $callOp * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -478,7 +483,7 @@ public function listFederations(ListFederationsRequest $request, array $callOpti * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * @@ -640,10 +645,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @experimental */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/Datastore/src/V1/Client/DatastoreClient.php b/Datastore/src/V1/Client/DatastoreClient.php index 656cb4c99f84..598cf77a204b 100644 --- a/Datastore/src/V1/Client/DatastoreClient.php +++ b/Datastore/src/V1/Client/DatastoreClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; use Google\ApiCore\ValidationException; @@ -123,25 +124,28 @@ private static function getClientDefaults() /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'datastore.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Datastore\V1\DatastoreClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new DatastoreClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -179,11 +183,13 @@ private static function getClientDefaults() * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/DatastoreAdmin/src/V1/Client/DatastoreAdminClient.php b/DatastoreAdmin/src/V1/Client/DatastoreAdminClient.php index f5fb0fd9b51a..1b4662429714 100644 --- a/DatastoreAdmin/src/V1/Client/DatastoreAdminClient.php +++ b/DatastoreAdmin/src/V1/Client/DatastoreAdminClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; @@ -36,6 +37,7 @@ use Google\Cloud\Datastore\Admin\V1\CreateIndexRequest; use Google\Cloud\Datastore\Admin\V1\DeleteIndexRequest; use Google\Cloud\Datastore\Admin\V1\ExportEntitiesRequest; +use Google\Cloud\Datastore\Admin\V1\ExportEntitiesResponse; use Google\Cloud\Datastore\Admin\V1\GetIndexRequest; use Google\Cloud\Datastore\Admin\V1\ImportEntitiesRequest; use Google\Cloud\Datastore\Admin\V1\Index; @@ -177,9 +179,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -207,25 +207,28 @@ private function createOperationsClient(array $options) /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'datastore.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Datastore\Admin\V1\DatastoreAdminClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new DatastoreAdminClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -263,11 +266,13 @@ private function createOperationsClient(array $options) * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -315,7 +320,7 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -351,7 +356,7 @@ public function createIndex(CreateIndexRequest $request, array $callOptions = [] * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -384,7 +389,7 @@ public function deleteIndex(DeleteIndexRequest $request, array $callOptions = [] * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -440,7 +445,7 @@ public function getIndex(GetIndexRequest $request, array $callOptions = []): Ind * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ diff --git a/Datastream/src/V1/Client/DatastreamClient.php b/Datastream/src/V1/Client/DatastreamClient.php index 452864f3c1b3..ffd789489964 100644 --- a/Datastream/src/V1/Client/DatastreamClient.php +++ b/Datastream/src/V1/Client/DatastreamClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -141,7 +142,9 @@ final class DatastreamClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -187,9 +190,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -316,12 +317,8 @@ public static function privateConnectionName(string $project, string $location, * * @return string The formatted route resource. */ - public static function routeName( - string $project, - string $location, - string $privateConnection, - string $route - ): string { + public static function routeName(string $project, string $location, string $privateConnection, string $route): string + { return self::getPathTemplate('route')->render([ 'project' => $project, 'location' => $location, @@ -404,25 +401,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'datastream.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Datastream\V1\DatastreamClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new DatastreamClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -460,11 +460,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -499,14 +501,12 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function createConnectionProfile( - CreateConnectionProfileRequest $request, - array $callOptions = [] - ): OperationResponse { + public function createConnectionProfile(CreateConnectionProfileRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('CreateConnectionProfile', $request, $callOptions)->wait(); } @@ -527,14 +527,12 @@ public function createConnectionProfile( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function createPrivateConnection( - CreatePrivateConnectionRequest $request, - array $callOptions = [] - ): OperationResponse { + public function createPrivateConnection(CreatePrivateConnectionRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('CreatePrivateConnection', $request, $callOptions)->wait(); } @@ -556,7 +554,7 @@ public function createPrivateConnection( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -582,7 +580,7 @@ public function createRoute(CreateRouteRequest $request, array $callOptions = [] * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -608,14 +606,12 @@ public function createStream(CreateStreamRequest $request, array $callOptions = * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function deleteConnectionProfile( - DeleteConnectionProfileRequest $request, - array $callOptions = [] - ): OperationResponse { + public function deleteConnectionProfile(DeleteConnectionProfileRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('DeleteConnectionProfile', $request, $callOptions)->wait(); } @@ -636,14 +632,12 @@ public function deleteConnectionProfile( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function deletePrivateConnection( - DeletePrivateConnectionRequest $request, - array $callOptions = [] - ): OperationResponse { + public function deletePrivateConnection(DeletePrivateConnectionRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('DeletePrivateConnection', $request, $callOptions)->wait(); } @@ -664,7 +658,7 @@ public function deletePrivateConnection( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -690,7 +684,7 @@ public function deleteRoute(DeleteRouteRequest $request, array $callOptions = [] * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -723,10 +717,8 @@ public function deleteStream(DeleteStreamRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function discoverConnectionProfile( - DiscoverConnectionProfileRequest $request, - array $callOptions = [] - ): DiscoverConnectionProfileResponse { + public function discoverConnectionProfile(DiscoverConnectionProfileRequest $request, array $callOptions = []): DiscoverConnectionProfileResponse + { return $this->startApiCall('DiscoverConnectionProfile', $request, $callOptions)->wait(); } @@ -778,10 +770,8 @@ public function fetchStaticIps(FetchStaticIpsRequest $request, array $callOption * * @throws ApiException Thrown if the API call fails. */ - public function getConnectionProfile( - GetConnectionProfileRequest $request, - array $callOptions = [] - ): ConnectionProfile { + public function getConnectionProfile(GetConnectionProfileRequest $request, array $callOptions = []): ConnectionProfile + { return $this->startApiCall('GetConnectionProfile', $request, $callOptions)->wait(); } @@ -806,10 +796,8 @@ public function getConnectionProfile( * * @throws ApiException Thrown if the API call fails. */ - public function getPrivateConnection( - GetPrivateConnectionRequest $request, - array $callOptions = [] - ): PrivateConnection { + public function getPrivateConnection(GetPrivateConnectionRequest $request, array $callOptions = []): PrivateConnection + { return $this->startApiCall('GetPrivateConnection', $request, $callOptions)->wait(); } @@ -913,10 +901,8 @@ public function getStreamObject(GetStreamObjectRequest $request, array $callOpti * * @throws ApiException Thrown if the API call fails. */ - public function listConnectionProfiles( - ListConnectionProfilesRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listConnectionProfiles(ListConnectionProfilesRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListConnectionProfiles', $request, $callOptions); } @@ -942,10 +928,8 @@ public function listConnectionProfiles( * * @throws ApiException Thrown if the API call fails. */ - public function listPrivateConnections( - ListPrivateConnectionsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listPrivateConnections(ListPrivateConnectionsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListPrivateConnections', $request, $callOptions); } @@ -1072,7 +1056,7 @@ public function lookupStreamObject(LookupStreamObjectRequest $request, array $ca * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1102,10 +1086,8 @@ public function runStream(RunStreamRequest $request, array $callOptions = []): O * * @throws ApiException Thrown if the API call fails. */ - public function startBackfillJob( - StartBackfillJobRequest $request, - array $callOptions = [] - ): StartBackfillJobResponse { + public function startBackfillJob(StartBackfillJobRequest $request, array $callOptions = []): StartBackfillJobResponse + { return $this->startApiCall('StartBackfillJob', $request, $callOptions)->wait(); } @@ -1152,14 +1134,12 @@ public function stopBackfillJob(StopBackfillJobRequest $request, array $callOpti * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function updateConnectionProfile( - UpdateConnectionProfileRequest $request, - array $callOptions = [] - ): OperationResponse { + public function updateConnectionProfile(UpdateConnectionProfileRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('UpdateConnectionProfile', $request, $callOptions)->wait(); } @@ -1180,7 +1160,7 @@ public function updateConnectionProfile( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ diff --git a/Deploy/src/V1/Client/CloudDeployClient.php b/Deploy/src/V1/Client/CloudDeployClient.php index 1e7c526aba19..67392abb398e 100644 --- a/Deploy/src/V1/Client/CloudDeployClient.php +++ b/Deploy/src/V1/Client/CloudDeployClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -199,7 +200,9 @@ final class CloudDeployClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -245,9 +248,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -283,12 +284,8 @@ private function createOperationsClient(array $options) * * @return string The formatted automation resource. */ - public static function automationName( - string $project, - string $location, - string $deliveryPipeline, - string $automation - ): string { + public static function automationName(string $project, string $location, string $deliveryPipeline, string $automation): string + { return self::getPathTemplate('automation')->render([ 'project' => $project, 'location' => $location, @@ -308,12 +305,8 @@ public static function automationName( * * @return string The formatted automation_run resource. */ - public static function automationRunName( - string $project, - string $location, - string $deliveryPipeline, - string $automationRun - ): string { + public static function automationRunName(string $project, string $location, string $deliveryPipeline, string $automationRun): string + { return self::getPathTemplate('automationRun')->render([ 'project' => $project, 'location' => $location, @@ -466,14 +459,8 @@ public static function jobName(string $project, string $location, string $job): * * @return string The formatted job_run resource. */ - public static function jobRunName( - string $project, - string $location, - string $deliveryPipeline, - string $release, - string $rollout, - string $jobRun - ): string { + public static function jobRunName(string $project, string $location, string $deliveryPipeline, string $release, string $rollout, string $jobRun): string + { return self::getPathTemplate('jobRun')->render([ 'project' => $project, 'location' => $location, @@ -531,12 +518,8 @@ public static function membershipName(string $project, string $location, string * * @return string The formatted release resource. */ - public static function releaseName( - string $project, - string $location, - string $deliveryPipeline, - string $release - ): string { + public static function releaseName(string $project, string $location, string $deliveryPipeline, string $release): string + { return self::getPathTemplate('release')->render([ 'project' => $project, 'location' => $location, @@ -556,12 +539,8 @@ public static function releaseName( * * @return string The formatted repository resource. */ - public static function repositoryName( - string $project, - string $location, - string $connection, - string $repository - ): string { + public static function repositoryName(string $project, string $location, string $connection, string $repository): string + { return self::getPathTemplate('repository')->render([ 'project' => $project, 'location' => $location, @@ -582,13 +561,8 @@ public static function repositoryName( * * @return string The formatted rollout resource. */ - public static function rolloutName( - string $project, - string $location, - string $deliveryPipeline, - string $release, - string $rollout - ): string { + public static function rolloutName(string $project, string $location, string $deliveryPipeline, string $release, string $rollout): string + { return self::getPathTemplate('rollout')->render([ 'project' => $project, 'location' => $location, @@ -699,25 +673,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'clouddeploy.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Deploy\V1\CloudDeployClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new CloudDeployClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -755,11 +732,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -879,10 +858,8 @@ public function approveRollout(ApproveRolloutRequest $request, array $callOption * * @throws ApiException Thrown if the API call fails. */ - public function cancelAutomationRun( - CancelAutomationRunRequest $request, - array $callOptions = [] - ): CancelAutomationRunResponse { + public function cancelAutomationRun(CancelAutomationRunRequest $request, array $callOptions = []): CancelAutomationRunResponse + { return $this->startApiCall('CancelAutomationRun', $request, $callOptions)->wait(); } @@ -929,7 +906,7 @@ public function cancelRollout(CancelRolloutRequest $request, array $callOptions * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -955,14 +932,12 @@ public function createAutomation(CreateAutomationRequest $request, array $callOp * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function createCustomTargetType( - CreateCustomTargetTypeRequest $request, - array $callOptions = [] - ): OperationResponse { + public function createCustomTargetType(CreateCustomTargetTypeRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('CreateCustomTargetType', $request, $callOptions)->wait(); } @@ -983,14 +958,12 @@ public function createCustomTargetType( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function createDeliveryPipeline( - CreateDeliveryPipelineRequest $request, - array $callOptions = [] - ): OperationResponse { + public function createDeliveryPipeline(CreateDeliveryPipelineRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('CreateDeliveryPipeline', $request, $callOptions)->wait(); } @@ -1011,7 +984,7 @@ public function createDeliveryPipeline( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1037,7 +1010,7 @@ public function createDeployPolicy(CreateDeployPolicyRequest $request, array $ca * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1063,7 +1036,7 @@ public function createRelease(CreateReleaseRequest $request, array $callOptions * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1089,7 +1062,7 @@ public function createRollout(CreateRolloutRequest $request, array $callOptions * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1115,7 +1088,7 @@ public function createTarget(CreateTargetRequest $request, array $callOptions = * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1141,14 +1114,12 @@ public function deleteAutomation(DeleteAutomationRequest $request, array $callOp * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function deleteCustomTargetType( - DeleteCustomTargetTypeRequest $request, - array $callOptions = [] - ): OperationResponse { + public function deleteCustomTargetType(DeleteCustomTargetTypeRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('DeleteCustomTargetType', $request, $callOptions)->wait(); } @@ -1169,14 +1140,12 @@ public function deleteCustomTargetType( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function deleteDeliveryPipeline( - DeleteDeliveryPipelineRequest $request, - array $callOptions = [] - ): OperationResponse { + public function deleteDeliveryPipeline(DeleteDeliveryPipelineRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('DeleteDeliveryPipeline', $request, $callOptions)->wait(); } @@ -1197,7 +1166,7 @@ public function deleteDeliveryPipeline( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1223,7 +1192,7 @@ public function deleteDeployPolicy(DeleteDeployPolicyRequest $request, array $ca * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1591,10 +1560,8 @@ public function listAutomations(ListAutomationsRequest $request, array $callOpti * * @throws ApiException Thrown if the API call fails. */ - public function listCustomTargetTypes( - ListCustomTargetTypesRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listCustomTargetTypes(ListCustomTargetTypesRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListCustomTargetTypes', $request, $callOptions); } @@ -1619,10 +1586,8 @@ public function listCustomTargetTypes( * * @throws ApiException Thrown if the API call fails. */ - public function listDeliveryPipelines( - ListDeliveryPipelinesRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listDeliveryPipelines(ListDeliveryPipelinesRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListDeliveryPipelines', $request, $callOptions); } @@ -1851,7 +1816,7 @@ public function terminateJobRun(TerminateJobRunRequest $request, array $callOpti * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1877,14 +1842,12 @@ public function updateAutomation(UpdateAutomationRequest $request, array $callOp * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function updateCustomTargetType( - UpdateCustomTargetTypeRequest $request, - array $callOptions = [] - ): OperationResponse { + public function updateCustomTargetType(UpdateCustomTargetTypeRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('UpdateCustomTargetType', $request, $callOptions)->wait(); } @@ -1905,14 +1868,12 @@ public function updateCustomTargetType( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function updateDeliveryPipeline( - UpdateDeliveryPipelineRequest $request, - array $callOptions = [] - ): OperationResponse { + public function updateDeliveryPipeline(UpdateDeliveryPipelineRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('UpdateDeliveryPipeline', $request, $callOptions)->wait(); } @@ -1933,7 +1894,7 @@ public function updateDeliveryPipeline( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1959,7 +1920,7 @@ public function updateDeployPolicy(UpdateDeployPolicyRequest $request, array $ca * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -2104,10 +2065,8 @@ public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); } } diff --git a/DeveloperConnect/src/V1/Client/DeveloperConnectClient.php b/DeveloperConnect/src/V1/Client/DeveloperConnectClient.php index 9b86b9a72252..56aa7d94c2ad 100644 --- a/DeveloperConnect/src/V1/Client/DeveloperConnectClient.php +++ b/DeveloperConnect/src/V1/Client/DeveloperConnectClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -137,7 +138,9 @@ final class DeveloperConnectClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -183,9 +186,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -280,12 +281,8 @@ public static function cryptoKeyName(string $project, string $location, string $ * * @return string The formatted git_repository_link resource. */ - public static function gitRepositoryLinkName( - string $project, - string $location, - string $connection, - string $gitRepositoryLink - ): string { + public static function gitRepositoryLinkName(string $project, string $location, string $connection, string $gitRepositoryLink): string + { return self::getPathTemplate('gitRepositoryLink')->render([ 'project' => $project, 'location' => $location, @@ -406,25 +403,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'developerconnect.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DeveloperConnect\V1\DeveloperConnectClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new DeveloperConnectClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -462,11 +462,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -502,14 +504,12 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function createAccountConnector( - CreateAccountConnectorRequest $request, - array $callOptions = [] - ): OperationResponse { + public function createAccountConnector(CreateAccountConnectorRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('CreateAccountConnector', $request, $callOptions)->wait(); } @@ -530,7 +530,7 @@ public function createAccountConnector( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -561,14 +561,12 @@ public function createConnection(CreateConnectionRequest $request, array $callOp * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function createGitRepositoryLink( - CreateGitRepositoryLinkRequest $request, - array $callOptions = [] - ): OperationResponse { + public function createGitRepositoryLink(CreateGitRepositoryLinkRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('CreateGitRepositoryLink', $request, $callOptions)->wait(); } @@ -590,14 +588,12 @@ public function createGitRepositoryLink( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function deleteAccountConnector( - DeleteAccountConnectorRequest $request, - array $callOptions = [] - ): OperationResponse { + public function deleteAccountConnector(DeleteAccountConnectorRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('DeleteAccountConnector', $request, $callOptions)->wait(); } @@ -618,7 +614,7 @@ public function deleteAccountConnector( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -645,14 +641,12 @@ public function deleteConnection(DeleteConnectionRequest $request, array $callOp * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function deleteGitRepositoryLink( - DeleteGitRepositoryLinkRequest $request, - array $callOptions = [] - ): OperationResponse { + public function deleteGitRepositoryLink(DeleteGitRepositoryLinkRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('DeleteGitRepositoryLink', $request, $callOptions)->wait(); } @@ -673,7 +667,7 @@ public function deleteGitRepositoryLink( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -699,7 +693,7 @@ public function deleteSelf(DeleteSelfRequest $request, array $callOptions = []): * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -729,10 +723,8 @@ public function deleteUser(DeleteUserRequest $request, array $callOptions = []): * * @throws ApiException Thrown if the API call fails. */ - public function fetchAccessToken( - FetchAccessTokenRequest $request, - array $callOptions = [] - ): FetchAccessTokenResponse { + public function fetchAccessToken(FetchAccessTokenRequest $request, array $callOptions = []): FetchAccessTokenResponse + { return $this->startApiCall('FetchAccessToken', $request, $callOptions)->wait(); } @@ -761,10 +753,8 @@ public function fetchAccessToken( * * @throws ApiException Thrown if the API call fails. */ - public function fetchGitHubInstallations( - FetchGitHubInstallationsRequest $request, - array $callOptions = [] - ): FetchGitHubInstallationsResponse { + public function fetchGitHubInstallations(FetchGitHubInstallationsRequest $request, array $callOptions = []): FetchGitHubInstallationsResponse + { return $this->startApiCall('FetchGitHubInstallations', $request, $callOptions)->wait(); } @@ -817,10 +807,8 @@ public function fetchGitRefs(FetchGitRefsRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function fetchLinkableGitRepositories( - FetchLinkableGitRepositoriesRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function fetchLinkableGitRepositories(FetchLinkableGitRepositoriesRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('FetchLinkableGitRepositories', $request, $callOptions); } @@ -871,10 +859,8 @@ public function fetchReadToken(FetchReadTokenRequest $request, array $callOption * * @throws ApiException Thrown if the API call fails. */ - public function fetchReadWriteToken( - FetchReadWriteTokenRequest $request, - array $callOptions = [] - ): FetchReadWriteTokenResponse { + public function fetchReadWriteToken(FetchReadWriteTokenRequest $request, array $callOptions = []): FetchReadWriteTokenResponse + { return $this->startApiCall('FetchReadWriteToken', $request, $callOptions)->wait(); } @@ -978,10 +964,8 @@ public function getConnection(GetConnectionRequest $request, array $callOptions * * @throws ApiException Thrown if the API call fails. */ - public function getGitRepositoryLink( - GetGitRepositoryLinkRequest $request, - array $callOptions = [] - ): GitRepositoryLink { + public function getGitRepositoryLink(GetGitRepositoryLinkRequest $request, array $callOptions = []): GitRepositoryLink + { return $this->startApiCall('GetGitRepositoryLink', $request, $callOptions)->wait(); } @@ -1007,10 +991,8 @@ public function getGitRepositoryLink( * * @throws ApiException Thrown if the API call fails. */ - public function listAccountConnectors( - ListAccountConnectorsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listAccountConnectors(ListAccountConnectorsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListAccountConnectors', $request, $callOptions); } @@ -1062,10 +1044,8 @@ public function listConnections(ListConnectionsRequest $request, array $callOpti * * @throws ApiException Thrown if the API call fails. */ - public function listGitRepositoryLinks( - ListGitRepositoryLinksRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listGitRepositoryLinks(ListGitRepositoryLinksRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListGitRepositoryLinks', $request, $callOptions); } @@ -1113,14 +1093,12 @@ public function listUsers(ListUsersRequest $request, array $callOptions = []): P * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function updateAccountConnector( - UpdateAccountConnectorRequest $request, - array $callOptions = [] - ): OperationResponse { + public function updateAccountConnector(UpdateAccountConnectorRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('UpdateAccountConnector', $request, $callOptions)->wait(); } @@ -1141,7 +1119,7 @@ public function updateAccountConnector( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ diff --git a/DeveloperConnect/src/V1/Client/InsightsConfigServiceClient.php b/DeveloperConnect/src/V1/Client/InsightsConfigServiceClient.php index 45ae5588aa9e..fd0270cda642 100644 --- a/DeveloperConnect/src/V1/Client/InsightsConfigServiceClient.php +++ b/DeveloperConnect/src/V1/Client/InsightsConfigServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -100,7 +101,9 @@ final class InsightsConfigServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -146,9 +149,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -237,25 +238,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'developerconnect.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DeveloperConnect\V1\InsightsConfigServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new InsightsConfigServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -293,11 +297,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -333,14 +339,12 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function createInsightsConfig( - CreateInsightsConfigRequest $request, - array $callOptions = [] - ): OperationResponse { + public function createInsightsConfig(CreateInsightsConfigRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('CreateInsightsConfig', $request, $callOptions)->wait(); } @@ -362,14 +366,12 @@ public function createInsightsConfig( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function deleteInsightsConfig( - DeleteInsightsConfigRequest $request, - array $callOptions = [] - ): OperationResponse { + public function deleteInsightsConfig(DeleteInsightsConfigRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('DeleteInsightsConfig', $request, $callOptions)->wait(); } @@ -445,14 +447,12 @@ public function listInsightsConfigs(ListInsightsConfigsRequest $request, array $ * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function updateInsightsConfig( - UpdateInsightsConfigRequest $request, - array $callOptions = [] - ): OperationResponse { + public function updateInsightsConfig(UpdateInsightsConfigRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('UpdateInsightsConfig', $request, $callOptions)->wait(); } diff --git a/DeviceStreaming/src/V1/Client/DirectAccessServiceClient.php b/DeviceStreaming/src/V1/Client/DirectAccessServiceClient.php index 7eb0220a8a0d..ee72b106f092 100644 --- a/DeviceStreaming/src/V1/Client/DirectAccessServiceClient.php +++ b/DeviceStreaming/src/V1/Client/DirectAccessServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\BidiStream; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -94,7 +95,9 @@ final class DirectAccessServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private static function getClientDefaults() { @@ -175,25 +178,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'devicestreaming.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DeviceStreaming\V1\DirectAccessServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new DirectAccessServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -231,11 +237,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/Dialogflow/src/V2/Client/AgentsClient.php b/Dialogflow/src/V2/Client/AgentsClient.php index 825903c670a7..8fc5d6a96a25 100644 --- a/Dialogflow/src/V2/Client/AgentsClient.php +++ b/Dialogflow/src/V2/Client/AgentsClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -152,9 +153,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -289,25 +288,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\V2\AgentsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new AgentsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -345,11 +347,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -417,7 +421,7 @@ public function deleteAgent(DeleteAgentRequest $request, array $callOptions = [] * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -522,7 +526,7 @@ public function getValidationResult(GetValidationResultRequest $request, array $ * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -572,7 +576,7 @@ public function importAgent(ImportAgentRequest $request, array $callOptions = [] * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -673,7 +677,7 @@ public function setAgent(SetAgentRequest $request, array $callOptions = []): Age * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ diff --git a/Dialogflow/src/V2/Client/AnswerRecordsClient.php b/Dialogflow/src/V2/Client/AnswerRecordsClient.php index 8ab1dd741066..0182ba0865e5 100644 --- a/Dialogflow/src/V2/Client/AnswerRecordsClient.php +++ b/Dialogflow/src/V2/Client/AnswerRecordsClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -251,12 +252,8 @@ public static function projectAnswerRecordName(string $project, string $answerRe * * @return string The formatted project_environment_user_session resource. */ - public static function projectEnvironmentUserSessionName( - string $project, - string $environment, - string $user, - string $session - ): string { + public static function projectEnvironmentUserSessionName(string $project, string $environment, string $user, string $session): string + { return self::getPathTemplate('projectEnvironmentUserSession')->render([ 'project' => $project, 'environment' => $environment, @@ -277,13 +274,8 @@ public static function projectEnvironmentUserSessionName( * * @return string The formatted project_environment_user_session_context resource. */ - public static function projectEnvironmentUserSessionContextName( - string $project, - string $environment, - string $user, - string $session, - string $context - ): string { + public static function projectEnvironmentUserSessionContextName(string $project, string $environment, string $user, string $session, string $context): string + { return self::getPathTemplate('projectEnvironmentUserSessionContext')->render([ 'project' => $project, 'environment' => $environment, @@ -337,11 +329,8 @@ public static function projectLocationAgentName(string $project, string $locatio * * @return string The formatted project_location_answer_record resource. */ - public static function projectLocationAnswerRecordName( - string $project, - string $location, - string $answerRecord - ): string { + public static function projectLocationAnswerRecordName(string $project, string $location, string $answerRecord): string + { return self::getPathTemplate('projectLocationAnswerRecord')->render([ 'project' => $project, 'location' => $location, @@ -361,13 +350,8 @@ public static function projectLocationAnswerRecordName( * * @return string The formatted project_location_environment_user_session resource. */ - public static function projectLocationEnvironmentUserSessionName( - string $project, - string $location, - string $environment, - string $user, - string $session - ): string { + public static function projectLocationEnvironmentUserSessionName(string $project, string $location, string $environment, string $user, string $session): string + { return self::getPathTemplate('projectLocationEnvironmentUserSession')->render([ 'project' => $project, 'location' => $location, @@ -390,14 +374,8 @@ public static function projectLocationEnvironmentUserSessionName( * * @return string The formatted project_location_environment_user_session_context resource. */ - public static function projectLocationEnvironmentUserSessionContextName( - string $project, - string $location, - string $environment, - string $user, - string $session, - string $context - ): string { + public static function projectLocationEnvironmentUserSessionContextName(string $project, string $location, string $environment, string $user, string $session, string $context): string + { return self::getPathTemplate('projectLocationEnvironmentUserSessionContext')->render([ 'project' => $project, 'location' => $location, @@ -457,12 +435,8 @@ public static function projectLocationSessionName(string $project, string $locat * * @return string The formatted project_location_session_context resource. */ - public static function projectLocationSessionContextName( - string $project, - string $location, - string $session, - string $context - ): string { + public static function projectLocationSessionContextName(string $project, string $location, string $session, string $context): string + { return self::getPathTemplate('projectLocationSessionContext')->render([ 'project' => $project, 'location' => $location, @@ -571,25 +545,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\V2\AnswerRecordsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new AnswerRecordsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -627,11 +604,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/Dialogflow/src/V2/Client/ContextsClient.php b/Dialogflow/src/V2/Client/ContextsClient.php index 66412e8fc962..eed6fbda8587 100644 --- a/Dialogflow/src/V2/Client/ContextsClient.php +++ b/Dialogflow/src/V2/Client/ContextsClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -145,12 +146,8 @@ public static function contextName(string $project, string $session, string $con * * @return string The formatted project_environment_user_session resource. */ - public static function projectEnvironmentUserSessionName( - string $project, - string $environment, - string $user, - string $session - ): string { + public static function projectEnvironmentUserSessionName(string $project, string $environment, string $user, string $session): string + { return self::getPathTemplate('projectEnvironmentUserSession')->render([ 'project' => $project, 'environment' => $environment, @@ -171,13 +168,8 @@ public static function projectEnvironmentUserSessionName( * * @return string The formatted project_environment_user_session_context resource. */ - public static function projectEnvironmentUserSessionContextName( - string $project, - string $environment, - string $user, - string $session, - string $context - ): string { + public static function projectEnvironmentUserSessionContextName(string $project, string $environment, string $user, string $session, string $context): string + { return self::getPathTemplate('projectEnvironmentUserSessionContext')->render([ 'project' => $project, 'environment' => $environment, @@ -199,13 +191,8 @@ public static function projectEnvironmentUserSessionContextName( * * @return string The formatted project_location_environment_user_session resource. */ - public static function projectLocationEnvironmentUserSessionName( - string $project, - string $location, - string $environment, - string $user, - string $session - ): string { + public static function projectLocationEnvironmentUserSessionName(string $project, string $location, string $environment, string $user, string $session): string + { return self::getPathTemplate('projectLocationEnvironmentUserSession')->render([ 'project' => $project, 'location' => $location, @@ -228,14 +215,8 @@ public static function projectLocationEnvironmentUserSessionName( * * @return string The formatted project_location_environment_user_session_context resource. */ - public static function projectLocationEnvironmentUserSessionContextName( - string $project, - string $location, - string $environment, - string $user, - string $session, - string $context - ): string { + public static function projectLocationEnvironmentUserSessionContextName(string $project, string $location, string $environment, string $user, string $session, string $context): string + { return self::getPathTemplate('projectLocationEnvironmentUserSessionContext')->render([ 'project' => $project, 'location' => $location, @@ -276,12 +257,8 @@ public static function projectLocationSessionName(string $project, string $locat * * @return string The formatted project_location_session_context resource. */ - public static function projectLocationSessionContextName( - string $project, - string $location, - string $session, - string $context - ): string { + public static function projectLocationSessionContextName(string $project, string $location, string $session, string $context): string + { return self::getPathTemplate('projectLocationSessionContext')->render([ 'project' => $project, 'location' => $location, @@ -379,25 +356,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\V2\ContextsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new ContextsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -435,11 +415,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/Dialogflow/src/V2/Client/ConversationDatasetsClient.php b/Dialogflow/src/V2/Client/ConversationDatasetsClient.php index 870494d7ccfb..3e98f2dfade5 100644 --- a/Dialogflow/src/V2/Client/ConversationDatasetsClient.php +++ b/Dialogflow/src/V2/Client/ConversationDatasetsClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -148,9 +149,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -185,11 +184,8 @@ private function createOperationsClient(array $options) * * @return string The formatted conversation_dataset resource. */ - public static function conversationDatasetName( - string $project, - string $location, - string $conversationDataset - ): string { + public static function conversationDatasetName(string $project, string $location, string $conversationDataset): string + { return self::getPathTemplate('conversationDataset')->render([ 'project' => $project, 'location' => $location, @@ -242,25 +238,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\V2\ConversationDatasetsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new ConversationDatasetsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -298,11 +297,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -347,14 +348,12 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function createConversationDataset( - CreateConversationDatasetRequest $request, - array $callOptions = [] - ): OperationResponse { + public function createConversationDataset(CreateConversationDatasetRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('CreateConversationDataset', $request, $callOptions)->wait(); } @@ -385,14 +384,12 @@ public function createConversationDataset( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function deleteConversationDataset( - DeleteConversationDatasetRequest $request, - array $callOptions = [] - ): OperationResponse { + public function deleteConversationDataset(DeleteConversationDatasetRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('DeleteConversationDataset', $request, $callOptions)->wait(); } @@ -418,10 +415,8 @@ public function deleteConversationDataset( * * @throws ApiException Thrown if the API call fails. */ - public function getConversationDataset( - GetConversationDatasetRequest $request, - array $callOptions = [] - ): ConversationDataset { + public function getConversationDataset(GetConversationDatasetRequest $request, array $callOptions = []): ConversationDataset + { return $this->startApiCall('GetConversationDataset', $request, $callOptions)->wait(); } @@ -454,14 +449,12 @@ public function getConversationDataset( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function importConversationData( - ImportConversationDataRequest $request, - array $callOptions = [] - ): OperationResponse { + public function importConversationData(ImportConversationDataRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('ImportConversationData', $request, $callOptions)->wait(); } @@ -488,10 +481,8 @@ public function importConversationData( * * @throws ApiException Thrown if the API call fails. */ - public function listConversationDatasets( - ListConversationDatasetsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listConversationDatasets(ListConversationDatasetsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListConversationDatasets', $request, $callOptions); } diff --git a/Dialogflow/src/V2/Client/ConversationModelsClient.php b/Dialogflow/src/V2/Client/ConversationModelsClient.php index 62a9cecfeb4b..7addb5b9aba6 100644 --- a/Dialogflow/src/V2/Client/ConversationModelsClient.php +++ b/Dialogflow/src/V2/Client/ConversationModelsClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -154,9 +155,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -191,11 +190,8 @@ private function createOperationsClient(array $options) * * @return string The formatted conversation_dataset resource. */ - public static function conversationDatasetName( - string $project, - string $location, - string $conversationDataset - ): string { + public static function conversationDatasetName(string $project, string $location, string $conversationDataset): string + { return self::getPathTemplate('conversationDataset')->render([ 'project' => $project, 'location' => $location, @@ -232,11 +228,8 @@ public static function conversationModelName(string $project, string $location, * * @return string The formatted conversation_model_evaluation resource. */ - public static function conversationModelEvaluationName( - string $project, - string $conversationModel, - string $evaluation - ): string { + public static function conversationModelEvaluationName(string $project, string $conversationModel, string $evaluation): string + { return self::getPathTemplate('conversationModelEvaluation')->render([ 'project' => $project, 'conversation_model' => $conversationModel, @@ -290,11 +283,8 @@ public static function projectConversationModelName(string $project, string $con * * @return string The formatted project_conversation_model_evaluation resource. */ - public static function projectConversationModelEvaluationName( - string $project, - string $conversationModel, - string $evaluation - ): string { + public static function projectConversationModelEvaluationName(string $project, string $conversationModel, string $evaluation): string + { return self::getPathTemplate('projectConversationModelEvaluation')->render([ 'project' => $project, 'conversation_model' => $conversationModel, @@ -312,11 +302,8 @@ public static function projectConversationModelEvaluationName( * * @return string The formatted project_knowledge_base_document resource. */ - public static function projectKnowledgeBaseDocumentName( - string $project, - string $knowledgeBase, - string $document - ): string { + public static function projectKnowledgeBaseDocumentName(string $project, string $knowledgeBase, string $document): string + { return self::getPathTemplate('projectKnowledgeBaseDocument')->render([ 'project' => $project, 'knowledge_base' => $knowledgeBase, @@ -334,11 +321,8 @@ public static function projectKnowledgeBaseDocumentName( * * @return string The formatted project_location_conversation_model resource. */ - public static function projectLocationConversationModelName( - string $project, - string $location, - string $conversationModel - ): string { + public static function projectLocationConversationModelName(string $project, string $location, string $conversationModel): string + { return self::getPathTemplate('projectLocationConversationModel')->render([ 'project' => $project, 'location' => $location, @@ -357,12 +341,8 @@ public static function projectLocationConversationModelName( * * @return string The formatted project_location_conversation_model_evaluation resource. */ - public static function projectLocationConversationModelEvaluationName( - string $project, - string $location, - string $conversationModel, - string $evaluation - ): string { + public static function projectLocationConversationModelEvaluationName(string $project, string $location, string $conversationModel, string $evaluation): string + { return self::getPathTemplate('projectLocationConversationModelEvaluation')->render([ 'project' => $project, 'location' => $location, @@ -382,12 +362,8 @@ public static function projectLocationConversationModelEvaluationName( * * @return string The formatted project_location_knowledge_base_document resource. */ - public static function projectLocationKnowledgeBaseDocumentName( - string $project, - string $location, - string $knowledgeBase, - string $document - ): string { + public static function projectLocationKnowledgeBaseDocumentName(string $project, string $location, string $knowledgeBase, string $document): string + { return self::getPathTemplate('projectLocationKnowledgeBaseDocument')->render([ 'project' => $project, 'location' => $location, @@ -432,25 +408,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\V2\ConversationModelsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new ConversationModelsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -488,11 +467,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -537,14 +518,12 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function createConversationModel( - CreateConversationModelRequest $request, - array $callOptions = [] - ): OperationResponse { + public function createConversationModel(CreateConversationModelRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('CreateConversationModel', $request, $callOptions)->wait(); } @@ -566,14 +545,12 @@ public function createConversationModel( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function createConversationModelEvaluation( - CreateConversationModelEvaluationRequest $request, - array $callOptions = [] - ): OperationResponse { + public function createConversationModelEvaluation(CreateConversationModelEvaluationRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('CreateConversationModelEvaluation', $request, $callOptions)->wait(); } @@ -604,14 +581,12 @@ public function createConversationModelEvaluation( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function deleteConversationModel( - DeleteConversationModelRequest $request, - array $callOptions = [] - ): OperationResponse { + public function deleteConversationModel(DeleteConversationModelRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('DeleteConversationModel', $request, $callOptions)->wait(); } @@ -645,14 +620,12 @@ public function deleteConversationModel( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function deployConversationModel( - DeployConversationModelRequest $request, - array $callOptions = [] - ): OperationResponse { + public function deployConversationModel(DeployConversationModelRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('DeployConversationModel', $request, $callOptions)->wait(); } @@ -678,10 +651,8 @@ public function deployConversationModel( * * @throws ApiException Thrown if the API call fails. */ - public function getConversationModel( - GetConversationModelRequest $request, - array $callOptions = [] - ): ConversationModel { + public function getConversationModel(GetConversationModelRequest $request, array $callOptions = []): ConversationModel + { return $this->startApiCall('GetConversationModel', $request, $callOptions)->wait(); } @@ -707,10 +678,8 @@ public function getConversationModel( * * @throws ApiException Thrown if the API call fails. */ - public function getConversationModelEvaluation( - GetConversationModelEvaluationRequest $request, - array $callOptions = [] - ): ConversationModelEvaluation { + public function getConversationModelEvaluation(GetConversationModelEvaluationRequest $request, array $callOptions = []): ConversationModelEvaluation + { return $this->startApiCall('GetConversationModelEvaluation', $request, $callOptions)->wait(); } @@ -736,10 +705,8 @@ public function getConversationModelEvaluation( * * @throws ApiException Thrown if the API call fails. */ - public function listConversationModelEvaluations( - ListConversationModelEvaluationsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listConversationModelEvaluations(ListConversationModelEvaluationsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListConversationModelEvaluations', $request, $callOptions); } @@ -765,10 +732,8 @@ public function listConversationModelEvaluations( * * @throws ApiException Thrown if the API call fails. */ - public function listConversationModels( - ListConversationModelsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listConversationModels(ListConversationModelsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListConversationModels', $request, $callOptions); } @@ -802,14 +767,12 @@ public function listConversationModels( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function undeployConversationModel( - UndeployConversationModelRequest $request, - array $callOptions = [] - ): OperationResponse { + public function undeployConversationModel(UndeployConversationModelRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('UndeployConversationModel', $request, $callOptions)->wait(); } diff --git a/Dialogflow/src/V2/Client/ConversationProfilesClient.php b/Dialogflow/src/V2/Client/ConversationProfilesClient.php index cb5e40719ed1..0df384614ea3 100644 --- a/Dialogflow/src/V2/Client/ConversationProfilesClient.php +++ b/Dialogflow/src/V2/Client/ConversationProfilesClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -148,9 +149,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -427,11 +426,8 @@ public static function projectKnowledgeBaseName(string $project, string $knowled * * @return string The formatted project_knowledge_base_document resource. */ - public static function projectKnowledgeBaseDocumentName( - string $project, - string $knowledgeBase, - string $document - ): string { + public static function projectKnowledgeBaseDocumentName(string $project, string $knowledgeBase, string $document): string + { return self::getPathTemplate('projectKnowledgeBaseDocument')->render([ 'project' => $project, 'knowledge_base' => $knowledgeBase, @@ -466,11 +462,8 @@ public static function projectLocationAgentName(string $project, string $locatio * * @return string The formatted project_location_conversation_model resource. */ - public static function projectLocationConversationModelName( - string $project, - string $location, - string $conversationModel - ): string { + public static function projectLocationConversationModelName(string $project, string $location, string $conversationModel): string + { return self::getPathTemplate('projectLocationConversationModel')->render([ 'project' => $project, 'location' => $location, @@ -488,11 +481,8 @@ public static function projectLocationConversationModelName( * * @return string The formatted project_location_conversation_profile resource. */ - public static function projectLocationConversationProfileName( - string $project, - string $location, - string $conversationProfile - ): string { + public static function projectLocationConversationProfileName(string $project, string $location, string $conversationProfile): string + { return self::getPathTemplate('projectLocationConversationProfile')->render([ 'project' => $project, 'location' => $location, @@ -510,11 +500,8 @@ public static function projectLocationConversationProfileName( * * @return string The formatted project_location_knowledge_base resource. */ - public static function projectLocationKnowledgeBaseName( - string $project, - string $location, - string $knowledgeBase - ): string { + public static function projectLocationKnowledgeBaseName(string $project, string $location, string $knowledgeBase): string + { return self::getPathTemplate('projectLocationKnowledgeBase')->render([ 'project' => $project, 'location' => $location, @@ -533,12 +520,8 @@ public static function projectLocationKnowledgeBaseName( * * @return string The formatted project_location_knowledge_base_document resource. */ - public static function projectLocationKnowledgeBaseDocumentName( - string $project, - string $location, - string $knowledgeBase, - string $document - ): string { + public static function projectLocationKnowledgeBaseDocumentName(string $project, string $location, string $knowledgeBase, string $document): string + { return self::getPathTemplate('projectLocationKnowledgeBaseDocument')->render([ 'project' => $project, 'location' => $location, @@ -593,25 +576,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\V2\ConversationProfilesClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new ConversationProfilesClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -649,11 +635,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -699,14 +687,12 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function clearSuggestionFeatureConfig( - ClearSuggestionFeatureConfigRequest $request, - array $callOptions = [] - ): OperationResponse { + public function clearSuggestionFeatureConfig(ClearSuggestionFeatureConfigRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('ClearSuggestionFeatureConfig', $request, $callOptions)->wait(); } @@ -739,10 +725,8 @@ public function clearSuggestionFeatureConfig( * * @throws ApiException Thrown if the API call fails. */ - public function createConversationProfile( - CreateConversationProfileRequest $request, - array $callOptions = [] - ): ConversationProfile { + public function createConversationProfile(CreateConversationProfileRequest $request, array $callOptions = []): ConversationProfile + { return $this->startApiCall('CreateConversationProfile', $request, $callOptions)->wait(); } @@ -793,10 +777,8 @@ public function deleteConversationProfile(DeleteConversationProfileRequest $requ * * @throws ApiException Thrown if the API call fails. */ - public function getConversationProfile( - GetConversationProfileRequest $request, - array $callOptions = [] - ): ConversationProfile { + public function getConversationProfile(GetConversationProfileRequest $request, array $callOptions = []): ConversationProfile + { return $this->startApiCall('GetConversationProfile', $request, $callOptions)->wait(); } @@ -822,10 +804,8 @@ public function getConversationProfile( * * @throws ApiException Thrown if the API call fails. */ - public function listConversationProfiles( - ListConversationProfilesRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listConversationProfiles(ListConversationProfilesRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListConversationProfiles', $request, $callOptions); } @@ -864,14 +844,12 @@ public function listConversationProfiles( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function setSuggestionFeatureConfig( - SetSuggestionFeatureConfigRequest $request, - array $callOptions = [] - ): OperationResponse { + public function setSuggestionFeatureConfig(SetSuggestionFeatureConfigRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('SetSuggestionFeatureConfig', $request, $callOptions)->wait(); } @@ -904,10 +882,8 @@ public function setSuggestionFeatureConfig( * * @throws ApiException Thrown if the API call fails. */ - public function updateConversationProfile( - UpdateConversationProfileRequest $request, - array $callOptions = [] - ): ConversationProfile { + public function updateConversationProfile(UpdateConversationProfileRequest $request, array $callOptions = []): ConversationProfile + { return $this->startApiCall('UpdateConversationProfile', $request, $callOptions)->wait(); } diff --git a/Dialogflow/src/V2/Client/ConversationsClient.php b/Dialogflow/src/V2/Client/ConversationsClient.php index 87adb674d176..f3a966aebaf9 100644 --- a/Dialogflow/src/V2/Client/ConversationsClient.php +++ b/Dialogflow/src/V2/Client/ConversationsClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -230,12 +231,8 @@ public static function conversationProfileName(string $project, string $conversa * * @return string The formatted data_store resource. */ - public static function dataStoreName( - string $project, - string $location, - string $collection, - string $dataStore - ): string { + public static function dataStoreName(string $project, string $location, string $collection, string $dataStore): string + { return self::getPathTemplate('dataStore')->render([ 'project' => $project, 'location' => $location, @@ -411,11 +408,8 @@ public static function projectConversationName(string $project, string $conversa * * @return string The formatted project_conversation_message resource. */ - public static function projectConversationMessageName( - string $project, - string $conversation, - string $message - ): string { + public static function projectConversationMessageName(string $project, string $conversation, string $message): string + { return self::getPathTemplate('projectConversationMessage')->render([ 'project' => $project, 'conversation' => $conversation, @@ -484,11 +478,8 @@ public static function projectKnowledgeBaseName(string $project, string $knowled * * @return string The formatted project_knowledge_base_document resource. */ - public static function projectKnowledgeBaseDocumentName( - string $project, - string $knowledgeBase, - string $document - ): string { + public static function projectKnowledgeBaseDocumentName(string $project, string $knowledgeBase, string $document): string + { return self::getPathTemplate('projectKnowledgeBaseDocument')->render([ 'project' => $project, 'knowledge_base' => $knowledgeBase, @@ -524,12 +515,8 @@ public static function projectLocationAgentName(string $project, string $locatio * * @return string The formatted project_location_collection_data_store resource. */ - public static function projectLocationCollectionDataStoreName( - string $project, - string $location, - string $collection, - string $dataStore - ): string { + public static function projectLocationCollectionDataStoreName(string $project, string $location, string $collection, string $dataStore): string + { return self::getPathTemplate('projectLocationCollectionDataStore')->render([ 'project' => $project, 'location' => $location, @@ -548,11 +535,8 @@ public static function projectLocationCollectionDataStoreName( * * @return string The formatted project_location_conversation resource. */ - public static function projectLocationConversationName( - string $project, - string $location, - string $conversation - ): string { + public static function projectLocationConversationName(string $project, string $location, string $conversation): string + { return self::getPathTemplate('projectLocationConversation')->render([ 'project' => $project, 'location' => $location, @@ -571,12 +555,8 @@ public static function projectLocationConversationName( * * @return string The formatted project_location_conversation_message resource. */ - public static function projectLocationConversationMessageName( - string $project, - string $location, - string $conversation, - string $message - ): string { + public static function projectLocationConversationMessageName(string $project, string $location, string $conversation, string $message): string + { return self::getPathTemplate('projectLocationConversationMessage')->render([ 'project' => $project, 'location' => $location, @@ -595,11 +575,8 @@ public static function projectLocationConversationMessageName( * * @return string The formatted project_location_conversation_model resource. */ - public static function projectLocationConversationModelName( - string $project, - string $location, - string $conversationModel - ): string { + public static function projectLocationConversationModelName(string $project, string $location, string $conversationModel): string + { return self::getPathTemplate('projectLocationConversationModel')->render([ 'project' => $project, 'location' => $location, @@ -617,11 +594,8 @@ public static function projectLocationConversationModelName( * * @return string The formatted project_location_conversation_profile resource. */ - public static function projectLocationConversationProfileName( - string $project, - string $location, - string $conversationProfile - ): string { + public static function projectLocationConversationProfileName(string $project, string $location, string $conversationProfile): string + { return self::getPathTemplate('projectLocationConversationProfile')->render([ 'project' => $project, 'location' => $location, @@ -658,11 +632,8 @@ public static function projectLocationDataStoreName(string $project, string $loc * * @return string The formatted project_location_knowledge_base resource. */ - public static function projectLocationKnowledgeBaseName( - string $project, - string $location, - string $knowledgeBase - ): string { + public static function projectLocationKnowledgeBaseName(string $project, string $location, string $knowledgeBase): string + { return self::getPathTemplate('projectLocationKnowledgeBase')->render([ 'project' => $project, 'location' => $location, @@ -681,12 +652,8 @@ public static function projectLocationKnowledgeBaseName( * * @return string The formatted project_location_knowledge_base_document resource. */ - public static function projectLocationKnowledgeBaseDocumentName( - string $project, - string $location, - string $knowledgeBase, - string $document - ): string { + public static function projectLocationKnowledgeBaseDocumentName(string $project, string $location, string $knowledgeBase, string $document): string + { return self::getPathTemplate('projectLocationKnowledgeBaseDocument')->render([ 'project' => $project, 'location' => $location, @@ -750,25 +717,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\V2\ConversationsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new ConversationsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -806,11 +776,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -923,10 +895,8 @@ public function createConversation(CreateConversationRequest $request, array $ca * * @throws ApiException Thrown if the API call fails. */ - public function generateStatelessSuggestion( - GenerateStatelessSuggestionRequest $request, - array $callOptions = [] - ): GenerateStatelessSuggestionResponse { + public function generateStatelessSuggestion(GenerateStatelessSuggestionRequest $request, array $callOptions = []): GenerateStatelessSuggestionResponse + { return $this->startApiCall('GenerateStatelessSuggestion', $request, $callOptions)->wait(); } @@ -953,10 +923,8 @@ public function generateStatelessSuggestion( * * @throws ApiException Thrown if the API call fails. */ - public function generateStatelessSummary( - GenerateStatelessSummaryRequest $request, - array $callOptions = [] - ): GenerateStatelessSummaryResponse { + public function generateStatelessSummary(GenerateStatelessSummaryRequest $request, array $callOptions = []): GenerateStatelessSummaryResponse + { return $this->startApiCall('GenerateStatelessSummary', $request, $callOptions)->wait(); } @@ -983,10 +951,8 @@ public function generateStatelessSummary( * * @throws ApiException Thrown if the API call fails. */ - public function generateSuggestions( - GenerateSuggestionsRequest $request, - array $callOptions = [] - ): GenerateSuggestionsResponse { + public function generateSuggestions(GenerateSuggestionsRequest $request, array $callOptions = []): GenerateSuggestionsResponse + { return $this->startApiCall('GenerateSuggestions', $request, $callOptions)->wait(); } @@ -1039,10 +1005,8 @@ public function getConversation(GetConversationRequest $request, array $callOpti * * @throws ApiException Thrown if the API call fails. */ - public function ingestContextReferences( - IngestContextReferencesRequest $request, - array $callOptions = [] - ): IngestContextReferencesResponse { + public function ingestContextReferences(IngestContextReferencesRequest $request, array $callOptions = []): IngestContextReferencesResponse + { return $this->startApiCall('IngestContextReferences', $request, $callOptions)->wait(); } @@ -1152,10 +1116,8 @@ public function searchKnowledge(SearchKnowledgeRequest $request, array $callOpti * * @throws ApiException Thrown if the API call fails. */ - public function suggestConversationSummary( - SuggestConversationSummaryRequest $request, - array $callOptions = [] - ): SuggestConversationSummaryResponse { + public function suggestConversationSummary(SuggestConversationSummaryRequest $request, array $callOptions = []): SuggestConversationSummaryResponse + { return $this->startApiCall('SuggestConversationSummary', $request, $callOptions)->wait(); } diff --git a/Dialogflow/src/V2/Client/DocumentsClient.php b/Dialogflow/src/V2/Client/DocumentsClient.php index c28fdaebd620..8650f8efda75 100644 --- a/Dialogflow/src/V2/Client/DocumentsClient.php +++ b/Dialogflow/src/V2/Client/DocumentsClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -150,9 +151,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -240,11 +239,8 @@ public static function projectKnowledgeBaseName(string $project, string $knowled * * @return string The formatted project_knowledge_base_document resource. */ - public static function projectKnowledgeBaseDocumentName( - string $project, - string $knowledgeBase, - string $document - ): string { + public static function projectKnowledgeBaseDocumentName(string $project, string $knowledgeBase, string $document): string + { return self::getPathTemplate('projectKnowledgeBaseDocument')->render([ 'project' => $project, 'knowledge_base' => $knowledgeBase, @@ -262,11 +258,8 @@ public static function projectKnowledgeBaseDocumentName( * * @return string The formatted project_location_knowledge_base resource. */ - public static function projectLocationKnowledgeBaseName( - string $project, - string $location, - string $knowledgeBase - ): string { + public static function projectLocationKnowledgeBaseName(string $project, string $location, string $knowledgeBase): string + { return self::getPathTemplate('projectLocationKnowledgeBase')->render([ 'project' => $project, 'location' => $location, @@ -285,12 +278,8 @@ public static function projectLocationKnowledgeBaseName( * * @return string The formatted project_location_knowledge_base_document resource. */ - public static function projectLocationKnowledgeBaseDocumentName( - string $project, - string $location, - string $knowledgeBase, - string $document - ): string { + public static function projectLocationKnowledgeBaseDocumentName(string $project, string $location, string $knowledgeBase, string $document): string + { return self::getPathTemplate('projectLocationKnowledgeBaseDocument')->render([ 'project' => $project, 'location' => $location, @@ -331,25 +320,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\V2\DocumentsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new DocumentsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -387,11 +379,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -434,7 +428,7 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -469,7 +463,7 @@ public function createDocument(CreateDocumentRequest $request, array $callOption * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -504,7 +498,7 @@ public function deleteDocument(DeleteDocumentRequest $request, array $callOption * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -567,7 +561,7 @@ public function getDocument(GetDocumentRequest $request, array $callOptions = [] * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -633,7 +627,7 @@ public function listDocuments(ListDocumentsRequest $request, array $callOptions * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -667,7 +661,7 @@ public function reloadDocument(ReloadDocumentRequest $request, array $callOption * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ diff --git a/Dialogflow/src/V2/Client/EncryptionSpecServiceClient.php b/Dialogflow/src/V2/Client/EncryptionSpecServiceClient.php index 917503fe1139..03095ccf5a49 100644 --- a/Dialogflow/src/V2/Client/EncryptionSpecServiceClient.php +++ b/Dialogflow/src/V2/Client/EncryptionSpecServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -37,6 +38,7 @@ use Google\Cloud\Dialogflow\V2\EncryptionSpec; use Google\Cloud\Dialogflow\V2\GetEncryptionSpecRequest; use Google\Cloud\Dialogflow\V2\InitializeEncryptionSpecRequest; +use Google\Cloud\Dialogflow\V2\InitializeEncryptionSpecResponse; use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; @@ -135,9 +137,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -206,25 +206,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\V2\EncryptionSpecServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new EncryptionSpecServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -262,11 +265,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -333,14 +338,12 @@ public function getEncryptionSpec(GetEncryptionSpecRequest $request, array $call * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function initializeEncryptionSpec( - InitializeEncryptionSpecRequest $request, - array $callOptions = [] - ): OperationResponse { + public function initializeEncryptionSpec(InitializeEncryptionSpecRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('InitializeEncryptionSpec', $request, $callOptions)->wait(); } diff --git a/Dialogflow/src/V2/Client/EntityTypesClient.php b/Dialogflow/src/V2/Client/EntityTypesClient.php index a69af52da7fc..14969335d523 100644 --- a/Dialogflow/src/V2/Client/EntityTypesClient.php +++ b/Dialogflow/src/V2/Client/EntityTypesClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -154,9 +155,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -313,25 +312,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\V2\EntityTypesClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new EntityTypesClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -369,11 +371,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -421,7 +425,7 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -460,7 +464,7 @@ public function batchCreateEntities(BatchCreateEntitiesRequest $request, array $ * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -499,14 +503,12 @@ public function batchDeleteEntities(BatchDeleteEntitiesRequest $request, array $ * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function batchDeleteEntityTypes( - BatchDeleteEntityTypesRequest $request, - array $callOptions = [] - ): OperationResponse { + public function batchDeleteEntityTypes(BatchDeleteEntityTypesRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('BatchDeleteEntityTypes', $request, $callOptions)->wait(); } @@ -543,7 +545,7 @@ public function batchDeleteEntityTypes( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -582,14 +584,12 @@ public function batchUpdateEntities(BatchUpdateEntitiesRequest $request, array $ * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function batchUpdateEntityTypes( - BatchUpdateEntityTypesRequest $request, - array $callOptions = [] - ): OperationResponse { + public function batchUpdateEntityTypes(BatchUpdateEntityTypesRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('BatchUpdateEntityTypes', $request, $callOptions)->wait(); } diff --git a/Dialogflow/src/V2/Client/EnvironmentsClient.php b/Dialogflow/src/V2/Client/EnvironmentsClient.php index 83956dc250a4..4a5ad304d2d1 100644 --- a/Dialogflow/src/V2/Client/EnvironmentsClient.php +++ b/Dialogflow/src/V2/Client/EnvironmentsClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -236,11 +237,8 @@ public static function projectLocationAgentName(string $project, string $locatio * * @return string The formatted project_location_environment resource. */ - public static function projectLocationEnvironmentName( - string $project, - string $location, - string $environment - ): string { + public static function projectLocationEnvironmentName(string $project, string $location, string $environment): string + { return self::getPathTemplate('projectLocationEnvironment')->render([ 'project' => $project, 'location' => $location, @@ -356,25 +354,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\V2\EnvironmentsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new EnvironmentsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -412,11 +413,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -530,10 +533,8 @@ public function getEnvironment(GetEnvironmentRequest $request, array $callOption * * @throws ApiException Thrown if the API call fails. */ - public function getEnvironmentHistory( - GetEnvironmentHistoryRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function getEnvironmentHistory(GetEnvironmentHistoryRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('GetEnvironmentHistory', $request, $callOptions); } diff --git a/Dialogflow/src/V2/Client/FulfillmentsClient.php b/Dialogflow/src/V2/Client/FulfillmentsClient.php index cb8c87e1684a..a7ed384d6924 100644 --- a/Dialogflow/src/V2/Client/FulfillmentsClient.php +++ b/Dialogflow/src/V2/Client/FulfillmentsClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -183,25 +184,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\V2\FulfillmentsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new FulfillmentsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -239,11 +243,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/Dialogflow/src/V2/Client/GeneratorsClient.php b/Dialogflow/src/V2/Client/GeneratorsClient.php index 7711facffaa1..b891a18cb748 100644 --- a/Dialogflow/src/V2/Client/GeneratorsClient.php +++ b/Dialogflow/src/V2/Client/GeneratorsClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -179,25 +180,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\V2\GeneratorsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new GeneratorsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -235,11 +239,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/Dialogflow/src/V2/Client/IntentsClient.php b/Dialogflow/src/V2/Client/IntentsClient.php index 7bcbd911bd2d..37ea2d064b53 100644 --- a/Dialogflow/src/V2/Client/IntentsClient.php +++ b/Dialogflow/src/V2/Client/IntentsClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -147,9 +148,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -251,12 +250,8 @@ public static function projectAgentName(string $project): string * * @return string The formatted project_environment_user_session resource. */ - public static function projectEnvironmentUserSessionName( - string $project, - string $environment, - string $user, - string $session - ): string { + public static function projectEnvironmentUserSessionName(string $project, string $environment, string $user, string $session): string + { return self::getPathTemplate('projectEnvironmentUserSession')->render([ 'project' => $project, 'environment' => $environment, @@ -277,13 +272,8 @@ public static function projectEnvironmentUserSessionName( * * @return string The formatted project_environment_user_session_context resource. */ - public static function projectEnvironmentUserSessionContextName( - string $project, - string $environment, - string $user, - string $session, - string $context - ): string { + public static function projectEnvironmentUserSessionContextName(string $project, string $environment, string $user, string $session, string $context): string + { return self::getPathTemplate('projectEnvironmentUserSessionContext')->render([ 'project' => $project, 'environment' => $environment, @@ -339,13 +329,8 @@ public static function projectLocationAgentName(string $project, string $locatio * * @return string The formatted project_location_environment_user_session resource. */ - public static function projectLocationEnvironmentUserSessionName( - string $project, - string $location, - string $environment, - string $user, - string $session - ): string { + public static function projectLocationEnvironmentUserSessionName(string $project, string $location, string $environment, string $user, string $session): string + { return self::getPathTemplate('projectLocationEnvironmentUserSession')->render([ 'project' => $project, 'location' => $location, @@ -368,14 +353,8 @@ public static function projectLocationEnvironmentUserSessionName( * * @return string The formatted project_location_environment_user_session_context resource. */ - public static function projectLocationEnvironmentUserSessionContextName( - string $project, - string $location, - string $environment, - string $user, - string $session, - string $context - ): string { + public static function projectLocationEnvironmentUserSessionContextName(string $project, string $location, string $environment, string $user, string $session, string $context): string + { return self::getPathTemplate('projectLocationEnvironmentUserSessionContext')->render([ 'project' => $project, 'location' => $location, @@ -435,12 +414,8 @@ public static function projectLocationSessionName(string $project, string $locat * * @return string The formatted project_location_session_context resource. */ - public static function projectLocationSessionContextName( - string $project, - string $location, - string $session, - string $context - ): string { + public static function projectLocationSessionContextName(string $project, string $location, string $session, string $context): string + { return self::getPathTemplate('projectLocationSessionContext')->render([ 'project' => $project, 'location' => $location, @@ -544,25 +519,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\V2\IntentsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new IntentsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -600,11 +578,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -652,7 +632,7 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -691,7 +671,7 @@ public function batchDeleteIntents(BatchDeleteIntentsRequest $request, array $ca * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ diff --git a/Dialogflow/src/V2/Client/KnowledgeBasesClient.php b/Dialogflow/src/V2/Client/KnowledgeBasesClient.php index 469abf434da4..a2e0e6c08e31 100644 --- a/Dialogflow/src/V2/Client/KnowledgeBasesClient.php +++ b/Dialogflow/src/V2/Client/KnowledgeBasesClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -190,11 +191,8 @@ public static function projectKnowledgeBaseName(string $project, string $knowled * * @return string The formatted project_location_knowledge_base resource. */ - public static function projectLocationKnowledgeBaseName( - string $project, - string $location, - string $knowledgeBase - ): string { + public static function projectLocationKnowledgeBaseName(string $project, string $location, string $knowledgeBase): string + { return self::getPathTemplate('projectLocationKnowledgeBase')->render([ 'project' => $project, 'location' => $location, @@ -233,25 +231,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\V2\KnowledgeBasesClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new KnowledgeBasesClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -289,11 +290,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/Dialogflow/src/V2/Client/ParticipantsClient.php b/Dialogflow/src/V2/Client/ParticipantsClient.php index 80d02d8bbb50..6a003b5c1e23 100644 --- a/Dialogflow/src/V2/Client/ParticipantsClient.php +++ b/Dialogflow/src/V2/Client/ParticipantsClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\BidiStream; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -247,11 +248,8 @@ public static function projectConversationName(string $project, string $conversa * * @return string The formatted project_conversation_message resource. */ - public static function projectConversationMessageName( - string $project, - string $conversation, - string $message - ): string { + public static function projectConversationMessageName(string $project, string $conversation, string $message): string + { return self::getPathTemplate('projectConversationMessage')->render([ 'project' => $project, 'conversation' => $conversation, @@ -269,11 +267,8 @@ public static function projectConversationMessageName( * * @return string The formatted project_conversation_participant resource. */ - public static function projectConversationParticipantName( - string $project, - string $conversation, - string $participant - ): string { + public static function projectConversationParticipantName(string $project, string $conversation, string $participant): string + { return self::getPathTemplate('projectConversationParticipant')->render([ 'project' => $project, 'conversation' => $conversation, @@ -292,12 +287,8 @@ public static function projectConversationParticipantName( * * @return string The formatted project_environment_user_session resource. */ - public static function projectEnvironmentUserSessionName( - string $project, - string $environment, - string $user, - string $session - ): string { + public static function projectEnvironmentUserSessionName(string $project, string $environment, string $user, string $session): string + { return self::getPathTemplate('projectEnvironmentUserSession')->render([ 'project' => $project, 'environment' => $environment, @@ -318,13 +309,8 @@ public static function projectEnvironmentUserSessionName( * * @return string The formatted project_environment_user_session_context resource. */ - public static function projectEnvironmentUserSessionContextName( - string $project, - string $environment, - string $user, - string $session, - string $context - ): string { + public static function projectEnvironmentUserSessionContextName(string $project, string $environment, string $user, string $session, string $context): string + { return self::getPathTemplate('projectEnvironmentUserSessionContext')->render([ 'project' => $project, 'environment' => $environment, @@ -346,13 +332,8 @@ public static function projectEnvironmentUserSessionContextName( * * @return string The formatted project_environment_user_session_entity_type resource. */ - public static function projectEnvironmentUserSessionEntityTypeName( - string $project, - string $environment, - string $user, - string $session, - string $entityType - ): string { + public static function projectEnvironmentUserSessionEntityTypeName(string $project, string $environment, string $user, string $session, string $entityType): string + { return self::getPathTemplate('projectEnvironmentUserSessionEntityType')->render([ 'project' => $project, 'environment' => $environment, @@ -372,11 +353,8 @@ public static function projectEnvironmentUserSessionEntityTypeName( * * @return string The formatted project_location_conversation resource. */ - public static function projectLocationConversationName( - string $project, - string $location, - string $conversation - ): string { + public static function projectLocationConversationName(string $project, string $location, string $conversation): string + { return self::getPathTemplate('projectLocationConversation')->render([ 'project' => $project, 'location' => $location, @@ -395,12 +373,8 @@ public static function projectLocationConversationName( * * @return string The formatted project_location_conversation_message resource. */ - public static function projectLocationConversationMessageName( - string $project, - string $location, - string $conversation, - string $message - ): string { + public static function projectLocationConversationMessageName(string $project, string $location, string $conversation, string $message): string + { return self::getPathTemplate('projectLocationConversationMessage')->render([ 'project' => $project, 'location' => $location, @@ -420,12 +394,8 @@ public static function projectLocationConversationMessageName( * * @return string The formatted project_location_conversation_participant resource. */ - public static function projectLocationConversationParticipantName( - string $project, - string $location, - string $conversation, - string $participant - ): string { + public static function projectLocationConversationParticipantName(string $project, string $location, string $conversation, string $participant): string + { return self::getPathTemplate('projectLocationConversationParticipant')->render([ 'project' => $project, 'location' => $location, @@ -446,13 +416,8 @@ public static function projectLocationConversationParticipantName( * * @return string The formatted project_location_environment_user_session resource. */ - public static function projectLocationEnvironmentUserSessionName( - string $project, - string $location, - string $environment, - string $user, - string $session - ): string { + public static function projectLocationEnvironmentUserSessionName(string $project, string $location, string $environment, string $user, string $session): string + { return self::getPathTemplate('projectLocationEnvironmentUserSession')->render([ 'project' => $project, 'location' => $location, @@ -475,14 +440,8 @@ public static function projectLocationEnvironmentUserSessionName( * * @return string The formatted project_location_environment_user_session_context resource. */ - public static function projectLocationEnvironmentUserSessionContextName( - string $project, - string $location, - string $environment, - string $user, - string $session, - string $context - ): string { + public static function projectLocationEnvironmentUserSessionContextName(string $project, string $location, string $environment, string $user, string $session, string $context): string + { return self::getPathTemplate('projectLocationEnvironmentUserSessionContext')->render([ 'project' => $project, 'location' => $location, @@ -506,14 +465,8 @@ public static function projectLocationEnvironmentUserSessionContextName( * * @return string The formatted project_location_environment_user_session_entity_type resource. */ - public static function projectLocationEnvironmentUserSessionEntityTypeName( - string $project, - string $location, - string $environment, - string $user, - string $session, - string $entityType - ): string { + public static function projectLocationEnvironmentUserSessionEntityTypeName(string $project, string $location, string $environment, string $user, string $session, string $entityType): string + { return self::getPathTemplate('projectLocationEnvironmentUserSessionEntityType')->render([ 'project' => $project, 'location' => $location, @@ -554,12 +507,8 @@ public static function projectLocationSessionName(string $project, string $locat * * @return string The formatted project_location_session_context resource. */ - public static function projectLocationSessionContextName( - string $project, - string $location, - string $session, - string $context - ): string { + public static function projectLocationSessionContextName(string $project, string $location, string $session, string $context): string + { return self::getPathTemplate('projectLocationSessionContext')->render([ 'project' => $project, 'location' => $location, @@ -579,12 +528,8 @@ public static function projectLocationSessionContextName( * * @return string The formatted project_location_session_entity_type resource. */ - public static function projectLocationSessionEntityTypeName( - string $project, - string $location, - string $session, - string $entityType - ): string { + public static function projectLocationSessionEntityTypeName(string $project, string $location, string $session, string $entityType): string + { return self::getPathTemplate('projectLocationSessionEntityType')->render([ 'project' => $project, 'location' => $location, @@ -735,25 +680,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\V2\ParticipantsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new ParticipantsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -791,11 +739,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -1005,10 +955,8 @@ public function suggestArticles(SuggestArticlesRequest $request, array $callOpti * * @throws ApiException Thrown if the API call fails. */ - public function suggestFaqAnswers( - SuggestFaqAnswersRequest $request, - array $callOptions = [] - ): SuggestFaqAnswersResponse { + public function suggestFaqAnswers(SuggestFaqAnswersRequest $request, array $callOptions = []): SuggestFaqAnswersResponse + { return $this->startApiCall('SuggestFaqAnswers', $request, $callOptions)->wait(); } @@ -1033,10 +981,8 @@ public function suggestFaqAnswers( * * @throws ApiException Thrown if the API call fails. */ - public function suggestKnowledgeAssist( - SuggestKnowledgeAssistRequest $request, - array $callOptions = [] - ): SuggestKnowledgeAssistResponse { + public function suggestKnowledgeAssist(SuggestKnowledgeAssistRequest $request, array $callOptions = []): SuggestKnowledgeAssistResponse + { return $this->startApiCall('SuggestKnowledgeAssist', $request, $callOptions)->wait(); } @@ -1062,10 +1008,8 @@ public function suggestKnowledgeAssist( * * @throws ApiException Thrown if the API call fails. */ - public function suggestSmartReplies( - SuggestSmartRepliesRequest $request, - array $callOptions = [] - ): SuggestSmartRepliesResponse { + public function suggestSmartReplies(SuggestSmartRepliesRequest $request, array $callOptions = []): SuggestSmartRepliesResponse + { return $this->startApiCall('SuggestSmartReplies', $request, $callOptions)->wait(); } diff --git a/Dialogflow/src/V2/Client/SessionEntityTypesClient.php b/Dialogflow/src/V2/Client/SessionEntityTypesClient.php index c89f5a816f18..8356eaf11517 100644 --- a/Dialogflow/src/V2/Client/SessionEntityTypesClient.php +++ b/Dialogflow/src/V2/Client/SessionEntityTypesClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -125,12 +126,8 @@ private static function getClientDefaults() * * @return string The formatted project_environment_user_session resource. */ - public static function projectEnvironmentUserSessionName( - string $project, - string $environment, - string $user, - string $session - ): string { + public static function projectEnvironmentUserSessionName(string $project, string $environment, string $user, string $session): string + { return self::getPathTemplate('projectEnvironmentUserSession')->render([ 'project' => $project, 'environment' => $environment, @@ -151,13 +148,8 @@ public static function projectEnvironmentUserSessionName( * * @return string The formatted project_environment_user_session_entity_type resource. */ - public static function projectEnvironmentUserSessionEntityTypeName( - string $project, - string $environment, - string $user, - string $session, - string $entityType - ): string { + public static function projectEnvironmentUserSessionEntityTypeName(string $project, string $environment, string $user, string $session, string $entityType): string + { return self::getPathTemplate('projectEnvironmentUserSessionEntityType')->render([ 'project' => $project, 'environment' => $environment, @@ -179,13 +171,8 @@ public static function projectEnvironmentUserSessionEntityTypeName( * * @return string The formatted project_location_environment_user_session resource. */ - public static function projectLocationEnvironmentUserSessionName( - string $project, - string $location, - string $environment, - string $user, - string $session - ): string { + public static function projectLocationEnvironmentUserSessionName(string $project, string $location, string $environment, string $user, string $session): string + { return self::getPathTemplate('projectLocationEnvironmentUserSession')->render([ 'project' => $project, 'location' => $location, @@ -208,14 +195,8 @@ public static function projectLocationEnvironmentUserSessionName( * * @return string The formatted project_location_environment_user_session_entity_type resource. */ - public static function projectLocationEnvironmentUserSessionEntityTypeName( - string $project, - string $location, - string $environment, - string $user, - string $session, - string $entityType - ): string { + public static function projectLocationEnvironmentUserSessionEntityTypeName(string $project, string $location, string $environment, string $user, string $session, string $entityType): string + { return self::getPathTemplate('projectLocationEnvironmentUserSessionEntityType')->render([ 'project' => $project, 'location' => $location, @@ -256,12 +237,8 @@ public static function projectLocationSessionName(string $project, string $locat * * @return string The formatted project_location_session_entity_type resource. */ - public static function projectLocationSessionEntityTypeName( - string $project, - string $location, - string $session, - string $entityType - ): string { + public static function projectLocationSessionEntityTypeName(string $project, string $location, string $session, string $entityType): string + { return self::getPathTemplate('projectLocationSessionEntityType')->render([ 'project' => $project, 'location' => $location, @@ -378,25 +355,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\V2\SessionEntityTypesClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new SessionEntityTypesClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -434,11 +414,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -484,10 +466,8 @@ public function __call($method, $args) * * @throws ApiException Thrown if the API call fails. */ - public function createSessionEntityType( - CreateSessionEntityTypeRequest $request, - array $callOptions = [] - ): SessionEntityType { + public function createSessionEntityType(CreateSessionEntityTypeRequest $request, array $callOptions = []): SessionEntityType + { return $this->startApiCall('CreateSessionEntityType', $request, $callOptions)->wait(); } @@ -546,10 +526,8 @@ public function deleteSessionEntityType(DeleteSessionEntityTypeRequest $request, * * @throws ApiException Thrown if the API call fails. */ - public function getSessionEntityType( - GetSessionEntityTypeRequest $request, - array $callOptions = [] - ): SessionEntityType { + public function getSessionEntityType(GetSessionEntityTypeRequest $request, array $callOptions = []): SessionEntityType + { return $this->startApiCall('GetSessionEntityType', $request, $callOptions)->wait(); } @@ -579,10 +557,8 @@ public function getSessionEntityType( * * @throws ApiException Thrown if the API call fails. */ - public function listSessionEntityTypes( - ListSessionEntityTypesRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listSessionEntityTypes(ListSessionEntityTypesRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListSessionEntityTypes', $request, $callOptions); } @@ -612,10 +588,8 @@ public function listSessionEntityTypes( * * @throws ApiException Thrown if the API call fails. */ - public function updateSessionEntityType( - UpdateSessionEntityTypeRequest $request, - array $callOptions = [] - ): SessionEntityType { + public function updateSessionEntityType(UpdateSessionEntityTypeRequest $request, array $callOptions = []): SessionEntityType + { return $this->startApiCall('UpdateSessionEntityType', $request, $callOptions)->wait(); } diff --git a/Dialogflow/src/V2/Client/SessionsClient.php b/Dialogflow/src/V2/Client/SessionsClient.php index 5ff2a014c2c4..e4a5048812a8 100644 --- a/Dialogflow/src/V2/Client/SessionsClient.php +++ b/Dialogflow/src/V2/Client/SessionsClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\BidiStream; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -158,12 +159,8 @@ public static function phraseSetName(string $project, string $location, string $ * * @return string The formatted project_environment_user_session resource. */ - public static function projectEnvironmentUserSessionName( - string $project, - string $environment, - string $user, - string $session - ): string { + public static function projectEnvironmentUserSessionName(string $project, string $environment, string $user, string $session): string + { return self::getPathTemplate('projectEnvironmentUserSession')->render([ 'project' => $project, 'environment' => $environment, @@ -184,13 +181,8 @@ public static function projectEnvironmentUserSessionName( * * @return string The formatted project_environment_user_session_context resource. */ - public static function projectEnvironmentUserSessionContextName( - string $project, - string $environment, - string $user, - string $session, - string $context - ): string { + public static function projectEnvironmentUserSessionContextName(string $project, string $environment, string $user, string $session, string $context): string + { return self::getPathTemplate('projectEnvironmentUserSessionContext')->render([ 'project' => $project, 'environment' => $environment, @@ -212,13 +204,8 @@ public static function projectEnvironmentUserSessionContextName( * * @return string The formatted project_environment_user_session_entity_type resource. */ - public static function projectEnvironmentUserSessionEntityTypeName( - string $project, - string $environment, - string $user, - string $session, - string $entityType - ): string { + public static function projectEnvironmentUserSessionEntityTypeName(string $project, string $environment, string $user, string $session, string $entityType): string + { return self::getPathTemplate('projectEnvironmentUserSessionEntityType')->render([ 'project' => $project, 'environment' => $environment, @@ -240,13 +227,8 @@ public static function projectEnvironmentUserSessionEntityTypeName( * * @return string The formatted project_location_environment_user_session resource. */ - public static function projectLocationEnvironmentUserSessionName( - string $project, - string $location, - string $environment, - string $user, - string $session - ): string { + public static function projectLocationEnvironmentUserSessionName(string $project, string $location, string $environment, string $user, string $session): string + { return self::getPathTemplate('projectLocationEnvironmentUserSession')->render([ 'project' => $project, 'location' => $location, @@ -269,14 +251,8 @@ public static function projectLocationEnvironmentUserSessionName( * * @return string The formatted project_location_environment_user_session_context resource. */ - public static function projectLocationEnvironmentUserSessionContextName( - string $project, - string $location, - string $environment, - string $user, - string $session, - string $context - ): string { + public static function projectLocationEnvironmentUserSessionContextName(string $project, string $location, string $environment, string $user, string $session, string $context): string + { return self::getPathTemplate('projectLocationEnvironmentUserSessionContext')->render([ 'project' => $project, 'location' => $location, @@ -300,14 +276,8 @@ public static function projectLocationEnvironmentUserSessionContextName( * * @return string The formatted project_location_environment_user_session_entity_type resource. */ - public static function projectLocationEnvironmentUserSessionEntityTypeName( - string $project, - string $location, - string $environment, - string $user, - string $session, - string $entityType - ): string { + public static function projectLocationEnvironmentUserSessionEntityTypeName(string $project, string $location, string $environment, string $user, string $session, string $entityType): string + { return self::getPathTemplate('projectLocationEnvironmentUserSessionEntityType')->render([ 'project' => $project, 'location' => $location, @@ -348,12 +318,8 @@ public static function projectLocationSessionName(string $project, string $locat * * @return string The formatted project_location_session_context resource. */ - public static function projectLocationSessionContextName( - string $project, - string $location, - string $session, - string $context - ): string { + public static function projectLocationSessionContextName(string $project, string $location, string $session, string $context): string + { return self::getPathTemplate('projectLocationSessionContext')->render([ 'project' => $project, 'location' => $location, @@ -373,12 +339,8 @@ public static function projectLocationSessionContextName( * * @return string The formatted project_location_session_entity_type resource. */ - public static function projectLocationSessionEntityTypeName( - string $project, - string $location, - string $session, - string $entityType - ): string { + public static function projectLocationSessionEntityTypeName(string $project, string $location, string $session, string $entityType): string + { return self::getPathTemplate('projectLocationSessionEntityType')->render([ 'project' => $project, 'location' => $location, @@ -520,25 +482,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\V2\SessionsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new SessionsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -576,11 +541,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/Dialogflow/src/V2/Client/VersionsClient.php b/Dialogflow/src/V2/Client/VersionsClient.php index ad11b292bb97..5cbc2ef8f378 100644 --- a/Dialogflow/src/V2/Client/VersionsClient.php +++ b/Dialogflow/src/V2/Client/VersionsClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -245,25 +246,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\V2\VersionsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new VersionsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -301,11 +305,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/DialogflowCx/src/V3/Client/AgentsClient.php b/DialogflowCx/src/V3/Client/AgentsClient.php index bc902e9ea101..e2c99d675eaa 100644 --- a/DialogflowCx/src/V3/Client/AgentsClient.php +++ b/DialogflowCx/src/V3/Client/AgentsClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -157,9 +158,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -252,12 +251,8 @@ public static function agentValidationResultName(string $project, string $locati * * @return string The formatted environment resource. */ - public static function environmentName( - string $project, - string $location, - string $agent, - string $environment - ): string { + public static function environmentName(string $project, string $location, string $agent, string $environment): string + { return self::getPathTemplate('environment')->render([ 'project' => $project, 'location' => $location, @@ -376,25 +371,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\Cx\V3\AgentsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new AgentsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -432,11 +430,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -534,7 +534,7 @@ public function deleteAgent(DeleteAgentRequest $request, array $callOptions = [] * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -591,10 +591,8 @@ public function getAgent(GetAgentRequest $request, array $callOptions = []): Age * * @throws ApiException Thrown if the API call fails. */ - public function getAgentValidationResult( - GetAgentValidationResultRequest $request, - array $callOptions = [] - ): AgentValidationResult { + public function getAgentValidationResult(GetAgentValidationResultRequest $request, array $callOptions = []): AgentValidationResult + { return $this->startApiCall('GetAgentValidationResult', $request, $callOptions)->wait(); } @@ -619,10 +617,8 @@ public function getAgentValidationResult( * * @throws ApiException Thrown if the API call fails. */ - public function getGenerativeSettings( - GetGenerativeSettingsRequest $request, - array $callOptions = [] - ): GenerativeSettings { + public function getGenerativeSettings(GetGenerativeSettingsRequest $request, array $callOptions = []): GenerativeSettings + { return $this->startApiCall('GetGenerativeSettings', $request, $callOptions)->wait(); } @@ -685,7 +681,7 @@ public function listAgents(ListAgentsRequest $request, array $callOptions = []): * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -745,10 +741,8 @@ public function updateAgent(UpdateAgentRequest $request, array $callOptions = [] * * @throws ApiException Thrown if the API call fails. */ - public function updateGenerativeSettings( - UpdateGenerativeSettingsRequest $request, - array $callOptions = [] - ): GenerativeSettings { + public function updateGenerativeSettings(UpdateGenerativeSettingsRequest $request, array $callOptions = []): GenerativeSettings + { return $this->startApiCall('UpdateGenerativeSettings', $request, $callOptions)->wait(); } diff --git a/DialogflowCx/src/V3/Client/ChangelogsClient.php b/DialogflowCx/src/V3/Client/ChangelogsClient.php index 774a81be526d..d162adeac358 100644 --- a/DialogflowCx/src/V3/Client/ChangelogsClient.php +++ b/DialogflowCx/src/V3/Client/ChangelogsClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -175,25 +176,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\Cx\V3\ChangelogsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new ChangelogsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -231,11 +235,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/DialogflowCx/src/V3/Client/DeploymentsClient.php b/DialogflowCx/src/V3/Client/DeploymentsClient.php index 077817533849..f484528a4aa4 100644 --- a/DialogflowCx/src/V3/Client/DeploymentsClient.php +++ b/DialogflowCx/src/V3/Client/DeploymentsClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -119,13 +120,8 @@ private static function getClientDefaults() * * @return string The formatted deployment resource. */ - public static function deploymentName( - string $project, - string $location, - string $agent, - string $environment, - string $deployment - ): string { + public static function deploymentName(string $project, string $location, string $agent, string $environment, string $deployment): string + { return self::getPathTemplate('deployment')->render([ 'project' => $project, 'location' => $location, @@ -146,12 +142,8 @@ public static function deploymentName( * * @return string The formatted environment resource. */ - public static function environmentName( - string $project, - string $location, - string $agent, - string $environment - ): string { + public static function environmentName(string $project, string $location, string $agent, string $environment): string + { return self::getPathTemplate('environment')->render([ 'project' => $project, 'location' => $location, @@ -188,25 +180,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\Cx\V3\DeploymentsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new DeploymentsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -244,11 +239,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/DialogflowCx/src/V3/Client/EntityTypesClient.php b/DialogflowCx/src/V3/Client/EntityTypesClient.php index a7aad644c8d7..a64d147edf19 100644 --- a/DialogflowCx/src/V3/Client/EntityTypesClient.php +++ b/DialogflowCx/src/V3/Client/EntityTypesClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -38,8 +39,10 @@ use Google\Cloud\Dialogflow\Cx\V3\DeleteEntityTypeRequest; use Google\Cloud\Dialogflow\Cx\V3\EntityType; use Google\Cloud\Dialogflow\Cx\V3\ExportEntityTypesRequest; +use Google\Cloud\Dialogflow\Cx\V3\ExportEntityTypesResponse; use Google\Cloud\Dialogflow\Cx\V3\GetEntityTypeRequest; use Google\Cloud\Dialogflow\Cx\V3\ImportEntityTypesRequest; +use Google\Cloud\Dialogflow\Cx\V3\ImportEntityTypesResponse; use Google\Cloud\Dialogflow\Cx\V3\ListEntityTypesRequest; use Google\Cloud\Dialogflow\Cx\V3\UpdateEntityTypeRequest; use Google\Cloud\Location\GetLocationRequest; @@ -145,9 +148,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -240,25 +241,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\Cx\V3\EntityTypesClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new EntityTypesClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -296,11 +300,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -393,7 +399,7 @@ public function deleteEntityType(DeleteEntityTypeRequest $request, array $callOp * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -445,7 +451,7 @@ public function getEntityType(GetEntityTypeRequest $request, array $callOptions * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ diff --git a/DialogflowCx/src/V3/Client/EnvironmentsClient.php b/DialogflowCx/src/V3/Client/EnvironmentsClient.php index 34cd296ecacc..b4a50fae60e2 100644 --- a/DialogflowCx/src/V3/Client/EnvironmentsClient.php +++ b/DialogflowCx/src/V3/Client/EnvironmentsClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -155,9 +156,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -212,12 +211,8 @@ public static function agentName(string $project, string $location, string $agen * * @return string The formatted environment resource. */ - public static function environmentName( - string $project, - string $location, - string $agent, - string $environment - ): string { + public static function environmentName(string $project, string $location, string $agent, string $environment): string + { return self::getPathTemplate('environment')->render([ 'project' => $project, 'location' => $location, @@ -280,13 +275,8 @@ public static function testCaseName(string $project, string $location, string $a * * @return string The formatted version resource. */ - public static function versionName( - string $project, - string $location, - string $agent, - string $flow, - string $version - ): string { + public static function versionName(string $project, string $location, string $agent, string $flow, string $version): string + { return self::getPathTemplate('version')->render([ 'project' => $project, 'location' => $location, @@ -349,25 +339,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\Cx\V3\EnvironmentsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new EnvironmentsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -405,11 +398,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -453,7 +448,7 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -514,7 +509,7 @@ public function deleteEnvironment(DeleteEnvironmentRequest $request, array $call * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -572,10 +567,8 @@ public function getEnvironment(GetEnvironmentRequest $request, array $callOption * * @throws ApiException Thrown if the API call fails. */ - public function listContinuousTestResults( - ListContinuousTestResultsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listContinuousTestResults(ListContinuousTestResultsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListContinuousTestResults', $request, $callOptions); } @@ -629,10 +622,8 @@ public function listEnvironments(ListEnvironmentsRequest $request, array $callOp * * @throws ApiException Thrown if the API call fails. */ - public function lookupEnvironmentHistory( - LookupEnvironmentHistoryRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function lookupEnvironmentHistory(LookupEnvironmentHistoryRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('LookupEnvironmentHistory', $request, $callOptions); } @@ -663,7 +654,7 @@ public function lookupEnvironmentHistory( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -698,7 +689,7 @@ public function runContinuousTest(RunContinuousTestRequest $request, array $call * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ diff --git a/DialogflowCx/src/V3/Client/ExperimentsClient.php b/DialogflowCx/src/V3/Client/ExperimentsClient.php index e173d503a2de..6d8e8caf8571 100644 --- a/DialogflowCx/src/V3/Client/ExperimentsClient.php +++ b/DialogflowCx/src/V3/Client/ExperimentsClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -128,12 +129,8 @@ private static function getClientDefaults() * * @return string The formatted environment resource. */ - public static function environmentName( - string $project, - string $location, - string $agent, - string $environment - ): string { + public static function environmentName(string $project, string $location, string $agent, string $environment): string + { return self::getPathTemplate('environment')->render([ 'project' => $project, 'location' => $location, @@ -154,13 +151,8 @@ public static function environmentName( * * @return string The formatted experiment resource. */ - public static function experimentName( - string $project, - string $location, - string $agent, - string $environment, - string $experiment - ): string { + public static function experimentName(string $project, string $location, string $agent, string $environment, string $experiment): string + { return self::getPathTemplate('experiment')->render([ 'project' => $project, 'location' => $location, @@ -182,13 +174,8 @@ public static function experimentName( * * @return string The formatted version resource. */ - public static function versionName( - string $project, - string $location, - string $agent, - string $flow, - string $version - ): string { + public static function versionName(string $project, string $location, string $agent, string $flow, string $version): string + { return self::getPathTemplate('version')->render([ 'project' => $project, 'location' => $location, @@ -227,25 +214,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\Cx\V3\ExperimentsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new ExperimentsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -283,11 +273,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/DialogflowCx/src/V3/Client/FlowsClient.php b/DialogflowCx/src/V3/Client/FlowsClient.php index 6fbdfafbe316..8b01c9b46265 100644 --- a/DialogflowCx/src/V3/Client/FlowsClient.php +++ b/DialogflowCx/src/V3/Client/FlowsClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -155,9 +156,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -233,12 +232,8 @@ public static function flowName(string $project, string $location, string $agent * * @return string The formatted flow_validation_result resource. */ - public static function flowValidationResultName( - string $project, - string $location, - string $agent, - string $flow - ): string { + public static function flowValidationResultName(string $project, string $location, string $agent, string $flow): string + { return self::getPathTemplate('flowValidationResult')->render([ 'project' => $project, 'location' => $location, @@ -301,13 +296,8 @@ public static function intentName(string $project, string $location, string $age * * @return string The formatted page resource. */ - public static function pageName( - string $project, - string $location, - string $agent, - string $flow, - string $page - ): string { + public static function pageName(string $project, string $location, string $agent, string $flow, string $page): string + { return self::getPathTemplate('page')->render([ 'project' => $project, 'location' => $location, @@ -329,13 +319,8 @@ public static function pageName( * * @return string The formatted project_location_agent_flow_transition_route_group resource. */ - public static function projectLocationAgentFlowTransitionRouteGroupName( - string $project, - string $location, - string $agent, - string $flow, - string $transitionRouteGroup - ): string { + public static function projectLocationAgentFlowTransitionRouteGroupName(string $project, string $location, string $agent, string $flow, string $transitionRouteGroup): string + { return self::getPathTemplate('projectLocationAgentFlowTransitionRouteGroup')->render([ 'project' => $project, 'location' => $location, @@ -356,12 +341,8 @@ public static function projectLocationAgentFlowTransitionRouteGroupName( * * @return string The formatted project_location_agent_transition_route_group resource. */ - public static function projectLocationAgentTransitionRouteGroupName( - string $project, - string $location, - string $agent, - string $transitionRouteGroup - ): string { + public static function projectLocationAgentTransitionRouteGroupName(string $project, string $location, string $agent, string $transitionRouteGroup): string + { return self::getPathTemplate('projectLocationAgentTransitionRouteGroup')->render([ 'project' => $project, 'location' => $location, @@ -382,13 +363,8 @@ public static function projectLocationAgentTransitionRouteGroupName( * * @return string The formatted transition_route_group resource. */ - public static function transitionRouteGroupName( - string $project, - string $location, - string $agent, - string $flow, - string $transitionRouteGroup - ): string { + public static function transitionRouteGroupName(string $project, string $location, string $agent, string $flow, string $transitionRouteGroup): string + { return self::getPathTemplate('transitionRouteGroup')->render([ 'project' => $project, 'location' => $location, @@ -455,25 +431,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\Cx\V3\FlowsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new FlowsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -511,11 +490,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -616,7 +597,7 @@ public function deleteFlow(DeleteFlowRequest $request, array $callOptions = []): * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -673,10 +654,8 @@ public function getFlow(GetFlowRequest $request, array $callOptions = []): Flow * * @throws ApiException Thrown if the API call fails. */ - public function getFlowValidationResult( - GetFlowValidationResultRequest $request, - array $callOptions = [] - ): FlowValidationResult { + public function getFlowValidationResult(GetFlowValidationResultRequest $request, array $callOptions = []): FlowValidationResult + { return $this->startApiCall('GetFlowValidationResult', $request, $callOptions)->wait(); } @@ -710,7 +689,7 @@ public function getFlowValidationResult( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -776,7 +755,7 @@ public function listFlows(ListFlowsRequest $request, array $callOptions = []): P * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ diff --git a/DialogflowCx/src/V3/Client/GeneratorsClient.php b/DialogflowCx/src/V3/Client/GeneratorsClient.php index 936ee6a9cb57..4efdb156767d 100644 --- a/DialogflowCx/src/V3/Client/GeneratorsClient.php +++ b/DialogflowCx/src/V3/Client/GeneratorsClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -181,25 +182,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\Cx\V3\GeneratorsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new GeneratorsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -237,11 +241,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/DialogflowCx/src/V3/Client/IntentsClient.php b/DialogflowCx/src/V3/Client/IntentsClient.php index 0774a42a9249..f5bf7213187c 100644 --- a/DialogflowCx/src/V3/Client/IntentsClient.php +++ b/DialogflowCx/src/V3/Client/IntentsClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -149,9 +150,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -266,25 +265,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\Cx\V3\IntentsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new IntentsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -322,11 +324,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -428,7 +432,7 @@ public function deleteIntent(DeleteIntentRequest $request, array $callOptions = * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -489,7 +493,7 @@ public function getIntent(GetIntentRequest $request, array $callOptions = []): I * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ diff --git a/DialogflowCx/src/V3/Client/PagesClient.php b/DialogflowCx/src/V3/Client/PagesClient.php index aca2d52a248f..bdfc30a2a508 100644 --- a/DialogflowCx/src/V3/Client/PagesClient.php +++ b/DialogflowCx/src/V3/Client/PagesClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -209,13 +210,8 @@ public static function intentName(string $project, string $location, string $age * * @return string The formatted page resource. */ - public static function pageName( - string $project, - string $location, - string $agent, - string $flow, - string $page - ): string { + public static function pageName(string $project, string $location, string $agent, string $flow, string $page): string + { return self::getPathTemplate('page')->render([ 'project' => $project, 'location' => $location, @@ -237,13 +233,8 @@ public static function pageName( * * @return string The formatted project_location_agent_flow_transition_route_group resource. */ - public static function projectLocationAgentFlowTransitionRouteGroupName( - string $project, - string $location, - string $agent, - string $flow, - string $transitionRouteGroup - ): string { + public static function projectLocationAgentFlowTransitionRouteGroupName(string $project, string $location, string $agent, string $flow, string $transitionRouteGroup): string + { return self::getPathTemplate('projectLocationAgentFlowTransitionRouteGroup')->render([ 'project' => $project, 'location' => $location, @@ -264,12 +255,8 @@ public static function projectLocationAgentFlowTransitionRouteGroupName( * * @return string The formatted project_location_agent_transition_route_group resource. */ - public static function projectLocationAgentTransitionRouteGroupName( - string $project, - string $location, - string $agent, - string $transitionRouteGroup - ): string { + public static function projectLocationAgentTransitionRouteGroupName(string $project, string $location, string $agent, string $transitionRouteGroup): string + { return self::getPathTemplate('projectLocationAgentTransitionRouteGroup')->render([ 'project' => $project, 'location' => $location, @@ -290,13 +277,8 @@ public static function projectLocationAgentTransitionRouteGroupName( * * @return string The formatted transition_route_group resource. */ - public static function transitionRouteGroupName( - string $project, - string $location, - string $agent, - string $flow, - string $transitionRouteGroup - ): string { + public static function transitionRouteGroupName(string $project, string $location, string $agent, string $flow, string $transitionRouteGroup): string + { return self::getPathTemplate('transitionRouteGroup')->render([ 'project' => $project, 'location' => $location, @@ -362,25 +344,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\Cx\V3\PagesClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new PagesClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -418,11 +403,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/DialogflowCx/src/V3/Client/SecuritySettingsServiceClient.php b/DialogflowCx/src/V3/Client/SecuritySettingsServiceClient.php index 1293bdf6d1c8..0fcc2a14d7c8 100644 --- a/DialogflowCx/src/V3/Client/SecuritySettingsServiceClient.php +++ b/DialogflowCx/src/V3/Client/SecuritySettingsServiceClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -107,8 +108,7 @@ private static function getClientDefaults() ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => - __DIR__ . '/../resources/security_settings_service_rest_client_config.php', + 'restClientConfigPath' => __DIR__ . '/../resources/security_settings_service_rest_client_config.php', ], ], ]; @@ -124,11 +124,8 @@ private static function getClientDefaults() * * @return string The formatted deidentify_template resource. */ - public static function deidentifyTemplateName( - string $organization, - string $location, - string $deidentifyTemplate - ): string { + public static function deidentifyTemplateName(string $organization, string $location, string $deidentifyTemplate): string + { return self::getPathTemplate('deidentifyTemplate')->render([ 'organization' => $organization, 'location' => $location, @@ -182,11 +179,8 @@ public static function locationName(string $project, string $location): string * * @return string The formatted organization_location_deidentify_template resource. */ - public static function organizationLocationDeidentifyTemplateName( - string $organization, - string $location, - string $deidentifyTemplate - ): string { + public static function organizationLocationDeidentifyTemplateName(string $organization, string $location, string $deidentifyTemplate): string + { return self::getPathTemplate('organizationLocationDeidentifyTemplate')->render([ 'organization' => $organization, 'location' => $location, @@ -204,11 +198,8 @@ public static function organizationLocationDeidentifyTemplateName( * * @return string The formatted organization_location_inspect_template resource. */ - public static function organizationLocationInspectTemplateName( - string $organization, - string $location, - string $inspectTemplate - ): string { + public static function organizationLocationInspectTemplateName(string $organization, string $location, string $inspectTemplate): string + { return self::getPathTemplate('organizationLocationInspectTemplate')->render([ 'organization' => $organization, 'location' => $location, @@ -226,11 +217,8 @@ public static function organizationLocationInspectTemplateName( * * @return string The formatted project_location_deidentify_template resource. */ - public static function projectLocationDeidentifyTemplateName( - string $project, - string $location, - string $deidentifyTemplate - ): string { + public static function projectLocationDeidentifyTemplateName(string $project, string $location, string $deidentifyTemplate): string + { return self::getPathTemplate('projectLocationDeidentifyTemplate')->render([ 'project' => $project, 'location' => $location, @@ -248,11 +236,8 @@ public static function projectLocationDeidentifyTemplateName( * * @return string The formatted project_location_inspect_template resource. */ - public static function projectLocationInspectTemplateName( - string $project, - string $location, - string $inspectTemplate - ): string { + public static function projectLocationInspectTemplateName(string $project, string $location, string $inspectTemplate): string + { return self::getPathTemplate('projectLocationInspectTemplate')->render([ 'project' => $project, 'location' => $location, @@ -313,25 +298,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\Cx\V3\SecuritySettingsServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new SecuritySettingsServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -369,11 +357,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -412,10 +402,8 @@ public function __call($method, $args) * * @throws ApiException Thrown if the API call fails. */ - public function createSecuritySettings( - CreateSecuritySettingsRequest $request, - array $callOptions = [] - ): SecuritySettings { + public function createSecuritySettings(CreateSecuritySettingsRequest $request, array $callOptions = []): SecuritySettings + { return $this->startApiCall('CreateSecuritySettings', $request, $callOptions)->wait(); } @@ -496,10 +484,8 @@ public function getSecuritySettings(GetSecuritySettingsRequest $request, array $ * * @throws ApiException Thrown if the API call fails. */ - public function listSecuritySettings( - ListSecuritySettingsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listSecuritySettings(ListSecuritySettingsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListSecuritySettings', $request, $callOptions); } @@ -526,10 +512,8 @@ public function listSecuritySettings( * * @throws ApiException Thrown if the API call fails. */ - public function updateSecuritySettings( - UpdateSecuritySettingsRequest $request, - array $callOptions = [] - ): SecuritySettings { + public function updateSecuritySettings(UpdateSecuritySettingsRequest $request, array $callOptions = []): SecuritySettings + { return $this->startApiCall('UpdateSecuritySettings', $request, $callOptions)->wait(); } diff --git a/DialogflowCx/src/V3/Client/SessionEntityTypesClient.php b/DialogflowCx/src/V3/Client/SessionEntityTypesClient.php index 731b5bbbd2af..279c630002a1 100644 --- a/DialogflowCx/src/V3/Client/SessionEntityTypesClient.php +++ b/DialogflowCx/src/V3/Client/SessionEntityTypesClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -126,13 +127,8 @@ private static function getClientDefaults() * * @return string The formatted project_location_agent_environment_session resource. */ - public static function projectLocationAgentEnvironmentSessionName( - string $project, - string $location, - string $agent, - string $environment, - string $session - ): string { + public static function projectLocationAgentEnvironmentSessionName(string $project, string $location, string $agent, string $environment, string $session): string + { return self::getPathTemplate('projectLocationAgentEnvironmentSession')->render([ 'project' => $project, 'location' => $location, @@ -155,14 +151,8 @@ public static function projectLocationAgentEnvironmentSessionName( * * @return string The formatted project_location_agent_environment_session_entity_type resource. */ - public static function projectLocationAgentEnvironmentSessionEntityTypeName( - string $project, - string $location, - string $agent, - string $environment, - string $session, - string $entityType - ): string { + public static function projectLocationAgentEnvironmentSessionEntityTypeName(string $project, string $location, string $agent, string $environment, string $session, string $entityType): string + { return self::getPathTemplate('projectLocationAgentEnvironmentSessionEntityType')->render([ 'project' => $project, 'location' => $location, @@ -184,12 +174,8 @@ public static function projectLocationAgentEnvironmentSessionEntityTypeName( * * @return string The formatted project_location_agent_session resource. */ - public static function projectLocationAgentSessionName( - string $project, - string $location, - string $agent, - string $session - ): string { + public static function projectLocationAgentSessionName(string $project, string $location, string $agent, string $session): string + { return self::getPathTemplate('projectLocationAgentSession')->render([ 'project' => $project, 'location' => $location, @@ -210,13 +196,8 @@ public static function projectLocationAgentSessionName( * * @return string The formatted project_location_agent_session_entity_type resource. */ - public static function projectLocationAgentSessionEntityTypeName( - string $project, - string $location, - string $agent, - string $session, - string $entityType - ): string { + public static function projectLocationAgentSessionEntityTypeName(string $project, string $location, string $agent, string $session, string $entityType): string + { return self::getPathTemplate('projectLocationAgentSessionEntityType')->render([ 'project' => $project, 'location' => $location, @@ -259,13 +240,8 @@ public static function sessionName(string $project, string $location, string $ag * * @return string The formatted session_entity_type resource. */ - public static function sessionEntityTypeName( - string $project, - string $location, - string $agent, - string $session, - string $entityType - ): string { + public static function sessionEntityTypeName(string $project, string $location, string $agent, string $session, string $entityType): string + { return self::getPathTemplate('sessionEntityType')->render([ 'project' => $project, 'location' => $location, @@ -307,25 +283,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\Cx\V3\SessionEntityTypesClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new SessionEntityTypesClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -363,11 +342,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -406,10 +387,8 @@ public function __call($method, $args) * * @throws ApiException Thrown if the API call fails. */ - public function createSessionEntityType( - CreateSessionEntityTypeRequest $request, - array $callOptions = [] - ): SessionEntityType { + public function createSessionEntityType(CreateSessionEntityTypeRequest $request, array $callOptions = []): SessionEntityType + { return $this->startApiCall('CreateSessionEntityType', $request, $callOptions)->wait(); } @@ -460,10 +439,8 @@ public function deleteSessionEntityType(DeleteSessionEntityTypeRequest $request, * * @throws ApiException Thrown if the API call fails. */ - public function getSessionEntityType( - GetSessionEntityTypeRequest $request, - array $callOptions = [] - ): SessionEntityType { + public function getSessionEntityType(GetSessionEntityTypeRequest $request, array $callOptions = []): SessionEntityType + { return $this->startApiCall('GetSessionEntityType', $request, $callOptions)->wait(); } @@ -489,10 +466,8 @@ public function getSessionEntityType( * * @throws ApiException Thrown if the API call fails. */ - public function listSessionEntityTypes( - ListSessionEntityTypesRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listSessionEntityTypes(ListSessionEntityTypesRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListSessionEntityTypes', $request, $callOptions); } @@ -518,10 +493,8 @@ public function listSessionEntityTypes( * * @throws ApiException Thrown if the API call fails. */ - public function updateSessionEntityType( - UpdateSessionEntityTypeRequest $request, - array $callOptions = [] - ): SessionEntityType { + public function updateSessionEntityType(UpdateSessionEntityTypeRequest $request, array $callOptions = []): SessionEntityType + { return $this->startApiCall('UpdateSessionEntityType', $request, $callOptions)->wait(); } diff --git a/DialogflowCx/src/V3/Client/SessionsClient.php b/DialogflowCx/src/V3/Client/SessionsClient.php index 64fb929f7ef2..f23d4f10c51c 100644 --- a/DialogflowCx/src/V3/Client/SessionsClient.php +++ b/DialogflowCx/src/V3/Client/SessionsClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\BidiStream; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -211,13 +212,8 @@ public static function intentName(string $project, string $location, string $age * * @return string The formatted page resource. */ - public static function pageName( - string $project, - string $location, - string $agent, - string $flow, - string $page - ): string { + public static function pageName(string $project, string $location, string $agent, string $flow, string $page): string + { return self::getPathTemplate('page')->render([ 'project' => $project, 'location' => $location, @@ -239,13 +235,8 @@ public static function pageName( * * @return string The formatted project_location_agent_environment_session resource. */ - public static function projectLocationAgentEnvironmentSessionName( - string $project, - string $location, - string $agent, - string $environment, - string $session - ): string { + public static function projectLocationAgentEnvironmentSessionName(string $project, string $location, string $agent, string $environment, string $session): string + { return self::getPathTemplate('projectLocationAgentEnvironmentSession')->render([ 'project' => $project, 'location' => $location, @@ -268,14 +259,8 @@ public static function projectLocationAgentEnvironmentSessionName( * * @return string The formatted project_location_agent_environment_session_entity_type resource. */ - public static function projectLocationAgentEnvironmentSessionEntityTypeName( - string $project, - string $location, - string $agent, - string $environment, - string $session, - string $entityType - ): string { + public static function projectLocationAgentEnvironmentSessionEntityTypeName(string $project, string $location, string $agent, string $environment, string $session, string $entityType): string + { return self::getPathTemplate('projectLocationAgentEnvironmentSessionEntityType')->render([ 'project' => $project, 'location' => $location, @@ -297,12 +282,8 @@ public static function projectLocationAgentEnvironmentSessionEntityTypeName( * * @return string The formatted project_location_agent_session resource. */ - public static function projectLocationAgentSessionName( - string $project, - string $location, - string $agent, - string $session - ): string { + public static function projectLocationAgentSessionName(string $project, string $location, string $agent, string $session): string + { return self::getPathTemplate('projectLocationAgentSession')->render([ 'project' => $project, 'location' => $location, @@ -323,13 +304,8 @@ public static function projectLocationAgentSessionName( * * @return string The formatted project_location_agent_session_entity_type resource. */ - public static function projectLocationAgentSessionEntityTypeName( - string $project, - string $location, - string $agent, - string $session, - string $entityType - ): string { + public static function projectLocationAgentSessionEntityTypeName(string $project, string $location, string $agent, string $session, string $entityType): string + { return self::getPathTemplate('projectLocationAgentSessionEntityType')->render([ 'project' => $project, 'location' => $location, @@ -350,12 +326,8 @@ public static function projectLocationAgentSessionEntityTypeName( * * @return string The formatted project_location_collection_data_store resource. */ - public static function projectLocationCollectionDataStoreName( - string $project, - string $location, - string $collection, - string $dataStore - ): string { + public static function projectLocationCollectionDataStoreName(string $project, string $location, string $collection, string $dataStore): string + { return self::getPathTemplate('projectLocationCollectionDataStore')->render([ 'project' => $project, 'location' => $location, @@ -416,13 +388,8 @@ public static function sessionName(string $project, string $location, string $ag * * @return string The formatted session_entity_type resource. */ - public static function sessionEntityTypeName( - string $project, - string $location, - string $agent, - string $session, - string $entityType - ): string { + public static function sessionEntityTypeName(string $project, string $location, string $agent, string $session, string $entityType): string + { return self::getPathTemplate('sessionEntityType')->render([ 'project' => $project, 'location' => $location, @@ -444,13 +411,8 @@ public static function sessionEntityTypeName( * * @return string The formatted version resource. */ - public static function versionName( - string $project, - string $location, - string $agent, - string $flow, - string $version - ): string { + public static function versionName(string $project, string $location, string $agent, string $flow, string $version): string + { return self::getPathTemplate('version')->render([ 'project' => $project, 'location' => $location, @@ -500,25 +462,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\Cx\V3\SessionsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new SessionsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -556,11 +521,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -686,7 +653,7 @@ public function matchIntent(MatchIntentRequest $request, array $callOptions = [] * Timeout to use for this call. * } * - * @return ServerStream + * @return ServerStream * * @throws ApiException Thrown if the API call fails. */ diff --git a/DialogflowCx/src/V3/Client/TestCasesClient.php b/DialogflowCx/src/V3/Client/TestCasesClient.php index f90ef093291e..a524fc82aa67 100644 --- a/DialogflowCx/src/V3/Client/TestCasesClient.php +++ b/DialogflowCx/src/V3/Client/TestCasesClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -166,9 +167,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -244,12 +243,8 @@ public static function entityTypeName(string $project, string $location, string * * @return string The formatted environment resource. */ - public static function environmentName( - string $project, - string $location, - string $agent, - string $environment - ): string { + public static function environmentName(string $project, string $location, string $agent, string $environment): string + { return self::getPathTemplate('environment')->render([ 'project' => $project, 'location' => $location, @@ -333,13 +328,8 @@ public static function intentName(string $project, string $location, string $age * * @return string The formatted page resource. */ - public static function pageName( - string $project, - string $location, - string $agent, - string $flow, - string $page - ): string { + public static function pageName(string $project, string $location, string $agent, string $flow, string $page): string + { return self::getPathTemplate('page')->render([ 'project' => $project, 'location' => $location, @@ -361,13 +351,8 @@ public static function pageName( * * @return string The formatted project_location_agent_flow_transition_route_group resource. */ - public static function projectLocationAgentFlowTransitionRouteGroupName( - string $project, - string $location, - string $agent, - string $flow, - string $transitionRouteGroup - ): string { + public static function projectLocationAgentFlowTransitionRouteGroupName(string $project, string $location, string $agent, string $flow, string $transitionRouteGroup): string + { return self::getPathTemplate('projectLocationAgentFlowTransitionRouteGroup')->render([ 'project' => $project, 'location' => $location, @@ -388,12 +373,8 @@ public static function projectLocationAgentFlowTransitionRouteGroupName( * * @return string The formatted project_location_agent_transition_route_group resource. */ - public static function projectLocationAgentTransitionRouteGroupName( - string $project, - string $location, - string $agent, - string $transitionRouteGroup - ): string { + public static function projectLocationAgentTransitionRouteGroupName(string $project, string $location, string $agent, string $transitionRouteGroup): string + { return self::getPathTemplate('projectLocationAgentTransitionRouteGroup')->render([ 'project' => $project, 'location' => $location, @@ -435,13 +416,8 @@ public static function testCaseName(string $project, string $location, string $a * * @return string The formatted test_case_result resource. */ - public static function testCaseResultName( - string $project, - string $location, - string $agent, - string $testCase, - string $result - ): string { + public static function testCaseResultName(string $project, string $location, string $agent, string $testCase, string $result): string + { return self::getPathTemplate('testCaseResult')->render([ 'project' => $project, 'location' => $location, @@ -463,13 +439,8 @@ public static function testCaseResultName( * * @return string The formatted transition_route_group resource. */ - public static function transitionRouteGroupName( - string $project, - string $location, - string $agent, - string $flow, - string $transitionRouteGroup - ): string { + public static function transitionRouteGroupName(string $project, string $location, string $agent, string $flow, string $transitionRouteGroup): string + { return self::getPathTemplate('transitionRouteGroup')->render([ 'project' => $project, 'location' => $location, @@ -539,25 +510,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new TestCasesClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -595,11 +569,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -667,7 +643,7 @@ public function batchDeleteTestCases(BatchDeleteTestCasesRequest $request, array * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -697,10 +673,8 @@ public function batchRunTestCases(BatchRunTestCasesRequest $request, array $call * * @throws ApiException Thrown if the API call fails. */ - public function calculateCoverage( - CalculateCoverageRequest $request, - array $callOptions = [] - ): CalculateCoverageResponse { + public function calculateCoverage(CalculateCoverageRequest $request, array $callOptions = []): CalculateCoverageResponse + { return $this->startApiCall('CalculateCoverage', $request, $callOptions)->wait(); } @@ -757,7 +731,7 @@ public function createTestCase(CreateTestCaseRequest $request, array $callOption * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -846,7 +820,7 @@ public function getTestCaseResult(GetTestCaseResultRequest $request, array $call * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -934,7 +908,7 @@ public function listTestCases(ListTestCasesRequest $request, array $callOptions * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ diff --git a/DialogflowCx/src/V3/Client/TransitionRouteGroupsClient.php b/DialogflowCx/src/V3/Client/TransitionRouteGroupsClient.php index a289e4a576e3..5de3cab07c41 100644 --- a/DialogflowCx/src/V3/Client/TransitionRouteGroupsClient.php +++ b/DialogflowCx/src/V3/Client/TransitionRouteGroupsClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -208,13 +209,8 @@ public static function intentName(string $project, string $location, string $age * * @return string The formatted page resource. */ - public static function pageName( - string $project, - string $location, - string $agent, - string $flow, - string $page - ): string { + public static function pageName(string $project, string $location, string $agent, string $flow, string $page): string + { return self::getPathTemplate('page')->render([ 'project' => $project, 'location' => $location, @@ -236,13 +232,8 @@ public static function pageName( * * @return string The formatted project_location_agent_flow_transition_route_group resource. */ - public static function projectLocationAgentFlowTransitionRouteGroupName( - string $project, - string $location, - string $agent, - string $flow, - string $transitionRouteGroup - ): string { + public static function projectLocationAgentFlowTransitionRouteGroupName(string $project, string $location, string $agent, string $flow, string $transitionRouteGroup): string + { return self::getPathTemplate('projectLocationAgentFlowTransitionRouteGroup')->render([ 'project' => $project, 'location' => $location, @@ -263,12 +254,8 @@ public static function projectLocationAgentFlowTransitionRouteGroupName( * * @return string The formatted project_location_agent_transition_route_group resource. */ - public static function projectLocationAgentTransitionRouteGroupName( - string $project, - string $location, - string $agent, - string $transitionRouteGroup - ): string { + public static function projectLocationAgentTransitionRouteGroupName(string $project, string $location, string $agent, string $transitionRouteGroup): string + { return self::getPathTemplate('projectLocationAgentTransitionRouteGroup')->render([ 'project' => $project, 'location' => $location, @@ -289,13 +276,8 @@ public static function projectLocationAgentTransitionRouteGroupName( * * @return string The formatted transition_route_group resource. */ - public static function transitionRouteGroupName( - string $project, - string $location, - string $agent, - string $flow, - string $transitionRouteGroup - ): string { + public static function transitionRouteGroupName(string $project, string $location, string $agent, string $flow, string $transitionRouteGroup): string + { return self::getPathTemplate('transitionRouteGroup')->render([ 'project' => $project, 'location' => $location, @@ -361,25 +343,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\Cx\V3\TransitionRouteGroupsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new TransitionRouteGroupsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -417,11 +402,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -466,10 +453,8 @@ public function __call($method, $args) * * @throws ApiException Thrown if the API call fails. */ - public function createTransitionRouteGroup( - CreateTransitionRouteGroupRequest $request, - array $callOptions = [] - ): TransitionRouteGroup { + public function createTransitionRouteGroup(CreateTransitionRouteGroupRequest $request, array $callOptions = []): TransitionRouteGroup + { return $this->startApiCall('CreateTransitionRouteGroup', $request, $callOptions)->wait(); } @@ -498,10 +483,8 @@ public function createTransitionRouteGroup( * * @throws ApiException Thrown if the API call fails. */ - public function deleteTransitionRouteGroup( - DeleteTransitionRouteGroupRequest $request, - array $callOptions = [] - ): void { + public function deleteTransitionRouteGroup(DeleteTransitionRouteGroupRequest $request, array $callOptions = []): void + { $this->startApiCall('DeleteTransitionRouteGroup', $request, $callOptions)->wait(); } @@ -528,10 +511,8 @@ public function deleteTransitionRouteGroup( * * @throws ApiException Thrown if the API call fails. */ - public function getTransitionRouteGroup( - GetTransitionRouteGroupRequest $request, - array $callOptions = [] - ): TransitionRouteGroup { + public function getTransitionRouteGroup(GetTransitionRouteGroupRequest $request, array $callOptions = []): TransitionRouteGroup + { return $this->startApiCall('GetTransitionRouteGroup', $request, $callOptions)->wait(); } @@ -557,10 +538,8 @@ public function getTransitionRouteGroup( * * @throws ApiException Thrown if the API call fails. */ - public function listTransitionRouteGroups( - ListTransitionRouteGroupsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listTransitionRouteGroups(ListTransitionRouteGroupsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListTransitionRouteGroups', $request, $callOptions); } @@ -591,10 +570,8 @@ public function listTransitionRouteGroups( * * @throws ApiException Thrown if the API call fails. */ - public function updateTransitionRouteGroup( - UpdateTransitionRouteGroupRequest $request, - array $callOptions = [] - ): TransitionRouteGroup { + public function updateTransitionRouteGroup(UpdateTransitionRouteGroupRequest $request, array $callOptions = []): TransitionRouteGroup + { return $this->startApiCall('UpdateTransitionRouteGroup', $request, $callOptions)->wait(); } diff --git a/DialogflowCx/src/V3/Client/VersionsClient.php b/DialogflowCx/src/V3/Client/VersionsClient.php index 12e6c2f5a713..d8e9dc0a55da 100644 --- a/DialogflowCx/src/V3/Client/VersionsClient.php +++ b/DialogflowCx/src/V3/Client/VersionsClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -148,9 +149,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -208,13 +207,8 @@ public static function flowName(string $project, string $location, string $agent * * @return string The formatted version resource. */ - public static function versionName( - string $project, - string $location, - string $agent, - string $flow, - string $version - ): string { + public static function versionName(string $project, string $location, string $agent, string $flow, string $version): string + { return self::getPathTemplate('version')->render([ 'project' => $project, 'location' => $location, @@ -252,25 +246,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\Cx\V3\VersionsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new VersionsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -308,11 +305,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -382,7 +381,7 @@ public function compareVersions(CompareVersionsRequest $request, array $callOpti * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -494,7 +493,7 @@ public function listVersions(ListVersionsRequest $request, array $callOptions = * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ diff --git a/DialogflowCx/src/V3/Client/WebhooksClient.php b/DialogflowCx/src/V3/Client/WebhooksClient.php index 042ff9863eef..4ac5c13254f8 100644 --- a/DialogflowCx/src/V3/Client/WebhooksClient.php +++ b/DialogflowCx/src/V3/Client/WebhooksClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -203,25 +204,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dialogflow.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dialogflow\Cx\V3\WebhooksClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new WebhooksClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -259,11 +263,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/DiscoveryEngine/src/V1/Client/AssistantServiceClient.php b/DiscoveryEngine/src/V1/Client/AssistantServiceClient.php index 1f67c28a98c7..59d256635e1c 100644 --- a/DiscoveryEngine/src/V1/Client/AssistantServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/AssistantServiceClient.php @@ -27,12 +27,14 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\ServerStream; use Google\ApiCore\Transport\TransportInterface; use Google\ApiCore\ValidationException; use Google\Auth\FetchAuthTokenInterface; use Google\Cloud\DiscoveryEngine\V1\StreamAssistRequest; +use Google\Cloud\DiscoveryEngine\V1\StreamAssistResponse; use Psr\Log\LoggerInterface; /** @@ -71,7 +73,9 @@ final class AssistantServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private static function getClientDefaults() { @@ -104,13 +108,8 @@ private static function getClientDefaults() * * @return string The formatted assistant resource. */ - public static function assistantName( - string $project, - string $location, - string $collection, - string $engine, - string $assistant - ): string { + public static function assistantName(string $project, string $location, string $collection, string $engine, string $assistant): string + { return self::getPathTemplate('assistant')->render([ 'project' => $project, 'location' => $location, @@ -150,12 +149,8 @@ public static function dataStoreName(string $project, string $location, string $ * * @return string The formatted project_location_collection_data_store resource. */ - public static function projectLocationCollectionDataStoreName( - string $project, - string $location, - string $collection, - string $dataStore - ): string { + public static function projectLocationCollectionDataStoreName(string $project, string $location, string $collection, string $dataStore): string + { return self::getPathTemplate('projectLocationCollectionDataStore')->render([ 'project' => $project, 'location' => $location, @@ -176,13 +171,8 @@ public static function projectLocationCollectionDataStoreName( * * @return string The formatted project_location_collection_data_store_session resource. */ - public static function projectLocationCollectionDataStoreSessionName( - string $project, - string $location, - string $collection, - string $dataStore, - string $session - ): string { + public static function projectLocationCollectionDataStoreSessionName(string $project, string $location, string $collection, string $dataStore, string $session): string + { return self::getPathTemplate('projectLocationCollectionDataStoreSession')->render([ 'project' => $project, 'location' => $location, @@ -204,13 +194,8 @@ public static function projectLocationCollectionDataStoreSessionName( * * @return string The formatted project_location_collection_engine_session resource. */ - public static function projectLocationCollectionEngineSessionName( - string $project, - string $location, - string $collection, - string $engine, - string $session - ): string { + public static function projectLocationCollectionEngineSessionName(string $project, string $location, string $collection, string $engine, string $session): string + { return self::getPathTemplate('projectLocationCollectionEngineSession')->render([ 'project' => $project, 'location' => $location, @@ -250,12 +235,8 @@ public static function projectLocationDataStoreName(string $project, string $loc * * @return string The formatted project_location_data_store_session resource. */ - public static function projectLocationDataStoreSessionName( - string $project, - string $location, - string $dataStore, - string $session - ): string { + public static function projectLocationDataStoreSessionName(string $project, string $location, string $dataStore, string $session): string + { return self::getPathTemplate('projectLocationDataStoreSession')->render([ 'project' => $project, 'location' => $location, @@ -319,25 +300,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'discoveryengine.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DiscoveryEngine\V1\AssistantServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new AssistantServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -375,11 +359,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -398,7 +384,7 @@ public function __construct(array $options = []) * Timeout to use for this call. * } * - * @return ServerStream + * @return ServerStream * * @throws ApiException Thrown if the API call fails. */ diff --git a/DiscoveryEngine/src/V1/Client/CmekConfigServiceClient.php b/DiscoveryEngine/src/V1/Client/CmekConfigServiceClient.php index 1496af9d89e1..6db6e537266d 100644 --- a/DiscoveryEngine/src/V1/Client/CmekConfigServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/CmekConfigServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; @@ -85,7 +86,9 @@ final class CmekConfigServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -131,9 +134,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -187,13 +188,8 @@ public static function cmekConfigName(string $project, string $location): string * * @return string The formatted crypto_key_versions resource. */ - public static function cryptoKeyVersionsName( - string $project, - string $location, - string $keyRing, - string $cryptoKey, - string $cryptoKeyVersion - ): string { + public static function cryptoKeyVersionsName(string $project, string $location, string $keyRing, string $cryptoKey, string $cryptoKeyVersion): string + { return self::getPathTemplate('cryptoKeyVersions')->render([ 'project' => $project, 'location' => $location, @@ -289,25 +285,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'discoveryengine.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DiscoveryEngine\V1\CmekConfigServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new CmekConfigServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -345,11 +344,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -384,7 +385,7 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -466,7 +467,7 @@ public function listCmekConfigs(ListCmekConfigsRequest $request, array $callOpti * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ diff --git a/DiscoveryEngine/src/V1/Client/CompletionServiceClient.php b/DiscoveryEngine/src/V1/Client/CompletionServiceClient.php index 7f8a3297e18a..ff758c0eaf5a 100644 --- a/DiscoveryEngine/src/V1/Client/CompletionServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/CompletionServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; @@ -36,9 +37,13 @@ use Google\Cloud\DiscoveryEngine\V1\CompleteQueryRequest; use Google\Cloud\DiscoveryEngine\V1\CompleteQueryResponse; use Google\Cloud\DiscoveryEngine\V1\ImportCompletionSuggestionsRequest; +use Google\Cloud\DiscoveryEngine\V1\ImportCompletionSuggestionsResponse; use Google\Cloud\DiscoveryEngine\V1\ImportSuggestionDenyListEntriesRequest; +use Google\Cloud\DiscoveryEngine\V1\ImportSuggestionDenyListEntriesResponse; use Google\Cloud\DiscoveryEngine\V1\PurgeCompletionSuggestionsRequest; +use Google\Cloud\DiscoveryEngine\V1\PurgeCompletionSuggestionsResponse; use Google\Cloud\DiscoveryEngine\V1\PurgeSuggestionDenyListEntriesRequest; +use Google\Cloud\DiscoveryEngine\V1\PurgeSuggestionDenyListEntriesResponse; use Google\LongRunning\Client\OperationsClient; use Google\LongRunning\Operation; use GuzzleHttp\Promise\PromiseInterface; @@ -86,7 +91,9 @@ final class CompletionServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -132,9 +139,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -189,12 +194,8 @@ public static function dataStoreName(string $project, string $location, string $ * * @return string The formatted project_location_collection_data_store resource. */ - public static function projectLocationCollectionDataStoreName( - string $project, - string $location, - string $collection, - string $dataStore - ): string { + public static function projectLocationCollectionDataStoreName(string $project, string $location, string $collection, string $dataStore): string + { return self::getPathTemplate('projectLocationCollectionDataStore')->render([ 'project' => $project, 'location' => $location, @@ -251,25 +252,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'discoveryengine.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DiscoveryEngine\V1\CompletionServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new CompletionServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -307,11 +311,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -375,14 +381,12 @@ public function completeQuery(CompleteQueryRequest $request, array $callOptions * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function importCompletionSuggestions( - ImportCompletionSuggestionsRequest $request, - array $callOptions = [] - ): OperationResponse { + public function importCompletionSuggestions(ImportCompletionSuggestionsRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('ImportCompletionSuggestions', $request, $callOptions)->wait(); } @@ -406,14 +410,12 @@ public function importCompletionSuggestions( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function importSuggestionDenyListEntries( - ImportSuggestionDenyListEntriesRequest $request, - array $callOptions = [] - ): OperationResponse { + public function importSuggestionDenyListEntries(ImportSuggestionDenyListEntriesRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('ImportSuggestionDenyListEntries', $request, $callOptions)->wait(); } @@ -437,14 +439,12 @@ public function importSuggestionDenyListEntries( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function purgeCompletionSuggestions( - PurgeCompletionSuggestionsRequest $request, - array $callOptions = [] - ): OperationResponse { + public function purgeCompletionSuggestions(PurgeCompletionSuggestionsRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('PurgeCompletionSuggestions', $request, $callOptions)->wait(); } @@ -468,14 +468,12 @@ public function purgeCompletionSuggestions( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function purgeSuggestionDenyListEntries( - PurgeSuggestionDenyListEntriesRequest $request, - array $callOptions = [] - ): OperationResponse { + public function purgeSuggestionDenyListEntries(PurgeSuggestionDenyListEntriesRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('PurgeSuggestionDenyListEntries', $request, $callOptions)->wait(); } } diff --git a/DiscoveryEngine/src/V1/Client/ControlServiceClient.php b/DiscoveryEngine/src/V1/Client/ControlServiceClient.php index c37c207df776..e5809246df8b 100644 --- a/DiscoveryEngine/src/V1/Client/ControlServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/ControlServiceClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -87,7 +88,9 @@ final class ControlServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private static function getClientDefaults() { @@ -160,13 +163,8 @@ public static function dataStoreName(string $project, string $location, string $ * * @return string The formatted document resource. */ - public static function documentName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document - ): string { + public static function documentName(string $project, string $location, string $dataStore, string $branch, string $document): string + { return self::getPathTemplate('document')->render([ 'project' => $project, 'location' => $location, @@ -208,12 +206,8 @@ public static function engineName(string $project, string $location, string $col * * @return string The formatted project_location_collection_data_store resource. */ - public static function projectLocationCollectionDataStoreName( - string $project, - string $location, - string $collection, - string $dataStore - ): string { + public static function projectLocationCollectionDataStoreName(string $project, string $location, string $collection, string $dataStore): string + { return self::getPathTemplate('projectLocationCollectionDataStore')->render([ 'project' => $project, 'location' => $location, @@ -235,14 +229,8 @@ public static function projectLocationCollectionDataStoreName( * * @return string The formatted project_location_collection_data_store_branch_document resource. */ - public static function projectLocationCollectionDataStoreBranchDocumentName( - string $project, - string $location, - string $collection, - string $dataStore, - string $branch, - string $document - ): string { + public static function projectLocationCollectionDataStoreBranchDocumentName(string $project, string $location, string $collection, string $dataStore, string $branch, string $document): string + { return self::getPathTemplate('projectLocationCollectionDataStoreBranchDocument')->render([ 'project' => $project, 'location' => $location, @@ -265,13 +253,8 @@ public static function projectLocationCollectionDataStoreBranchDocumentName( * * @return string The formatted project_location_collection_data_store_control resource. */ - public static function projectLocationCollectionDataStoreControlName( - string $project, - string $location, - string $collection, - string $dataStore, - string $control - ): string { + public static function projectLocationCollectionDataStoreControlName(string $project, string $location, string $collection, string $dataStore, string $control): string + { return self::getPathTemplate('projectLocationCollectionDataStoreControl')->render([ 'project' => $project, 'location' => $location, @@ -293,13 +276,8 @@ public static function projectLocationCollectionDataStoreControlName( * * @return string The formatted project_location_collection_engine_control resource. */ - public static function projectLocationCollectionEngineControlName( - string $project, - string $location, - string $collection, - string $engine, - string $control - ): string { + public static function projectLocationCollectionEngineControlName(string $project, string $location, string $collection, string $engine, string $control): string + { return self::getPathTemplate('projectLocationCollectionEngineControl')->render([ 'project' => $project, 'location' => $location, @@ -340,13 +318,8 @@ public static function projectLocationDataStoreName(string $project, string $loc * * @return string The formatted project_location_data_store_branch_document resource. */ - public static function projectLocationDataStoreBranchDocumentName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document - ): string { + public static function projectLocationDataStoreBranchDocumentName(string $project, string $location, string $dataStore, string $branch, string $document): string + { return self::getPathTemplate('projectLocationDataStoreBranchDocument')->render([ 'project' => $project, 'location' => $location, @@ -367,12 +340,8 @@ public static function projectLocationDataStoreBranchDocumentName( * * @return string The formatted project_location_data_store_control resource. */ - public static function projectLocationDataStoreControlName( - string $project, - string $location, - string $dataStore, - string $control - ): string { + public static function projectLocationDataStoreControlName(string $project, string $location, string $dataStore, string $control): string + { return self::getPathTemplate('projectLocationDataStoreControl')->render([ 'project' => $project, 'location' => $location, @@ -418,25 +387,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'discoveryengine.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DiscoveryEngine\V1\ControlServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new ControlServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -474,11 +446,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/DiscoveryEngine/src/V1/Client/ConversationalSearchServiceClient.php b/DiscoveryEngine/src/V1/Client/ConversationalSearchServiceClient.php index 44cacceeec8f..ea3289e48d77 100644 --- a/DiscoveryEngine/src/V1/Client/ConversationalSearchServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/ConversationalSearchServiceClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -105,7 +106,9 @@ final class ConversationalSearchServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private static function getClientDefaults() { @@ -120,8 +123,7 @@ private static function getClientDefaults() ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => - __DIR__ . '/../resources/conversational_search_service_rest_client_config.php', + 'restClientConfigPath' => __DIR__ . '/../resources/conversational_search_service_rest_client_config.php', ], ], ]; @@ -139,13 +141,8 @@ private static function getClientDefaults() * * @return string The formatted answer resource. */ - public static function answerName( - string $project, - string $location, - string $dataStore, - string $session, - string $answer - ): string { + public static function answerName(string $project, string $location, string $dataStore, string $session, string $answer): string + { return self::getPathTemplate('answer')->render([ 'project' => $project, 'location' => $location, @@ -168,14 +165,8 @@ public static function answerName( * * @return string The formatted chunk resource. */ - public static function chunkName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document, - string $chunk - ): string { + public static function chunkName(string $project, string $location, string $dataStore, string $branch, string $document, string $chunk): string + { return self::getPathTemplate('chunk')->render([ 'project' => $project, 'location' => $location, @@ -197,12 +188,8 @@ public static function chunkName( * * @return string The formatted conversation resource. */ - public static function conversationName( - string $project, - string $location, - string $dataStore, - string $conversation - ): string { + public static function conversationName(string $project, string $location, string $dataStore, string $conversation): string + { return self::getPathTemplate('conversation')->render([ 'project' => $project, 'location' => $location, @@ -242,13 +229,8 @@ public static function dataStoreName(string $project, string $location, string $ * * @return string The formatted document resource. */ - public static function documentName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document - ): string { + public static function documentName(string $project, string $location, string $dataStore, string $branch, string $document): string + { return self::getPathTemplate('document')->render([ 'project' => $project, 'location' => $location, @@ -269,12 +251,8 @@ public static function documentName( * * @return string The formatted project_location_collection_data_store resource. */ - public static function projectLocationCollectionDataStoreName( - string $project, - string $location, - string $collection, - string $dataStore - ): string { + public static function projectLocationCollectionDataStoreName(string $project, string $location, string $collection, string $dataStore): string + { return self::getPathTemplate('projectLocationCollectionDataStore')->render([ 'project' => $project, 'location' => $location, @@ -296,14 +274,8 @@ public static function projectLocationCollectionDataStoreName( * * @return string The formatted project_location_collection_data_store_branch_document resource. */ - public static function projectLocationCollectionDataStoreBranchDocumentName( - string $project, - string $location, - string $collection, - string $dataStore, - string $branch, - string $document - ): string { + public static function projectLocationCollectionDataStoreBranchDocumentName(string $project, string $location, string $collection, string $dataStore, string $branch, string $document): string + { return self::getPathTemplate('projectLocationCollectionDataStoreBranchDocument')->render([ 'project' => $project, 'location' => $location, @@ -328,15 +300,8 @@ public static function projectLocationCollectionDataStoreBranchDocumentName( * * @return string The formatted project_location_collection_data_store_branch_document_chunk resource. */ - public static function projectLocationCollectionDataStoreBranchDocumentChunkName( - string $project, - string $location, - string $collection, - string $dataStore, - string $branch, - string $document, - string $chunk - ): string { + public static function projectLocationCollectionDataStoreBranchDocumentChunkName(string $project, string $location, string $collection, string $dataStore, string $branch, string $document, string $chunk): string + { return self::getPathTemplate('projectLocationCollectionDataStoreBranchDocumentChunk')->render([ 'project' => $project, 'location' => $location, @@ -360,13 +325,8 @@ public static function projectLocationCollectionDataStoreBranchDocumentChunkName * * @return string The formatted project_location_collection_data_store_conversation resource. */ - public static function projectLocationCollectionDataStoreConversationName( - string $project, - string $location, - string $collection, - string $dataStore, - string $conversation - ): string { + public static function projectLocationCollectionDataStoreConversationName(string $project, string $location, string $collection, string $dataStore, string $conversation): string + { return self::getPathTemplate('projectLocationCollectionDataStoreConversation')->render([ 'project' => $project, 'location' => $location, @@ -388,13 +348,8 @@ public static function projectLocationCollectionDataStoreConversationName( * * @return string The formatted project_location_collection_data_store_serving_config resource. */ - public static function projectLocationCollectionDataStoreServingConfigName( - string $project, - string $location, - string $collection, - string $dataStore, - string $servingConfig - ): string { + public static function projectLocationCollectionDataStoreServingConfigName(string $project, string $location, string $collection, string $dataStore, string $servingConfig): string + { return self::getPathTemplate('projectLocationCollectionDataStoreServingConfig')->render([ 'project' => $project, 'location' => $location, @@ -416,13 +371,8 @@ public static function projectLocationCollectionDataStoreServingConfigName( * * @return string The formatted project_location_collection_data_store_session resource. */ - public static function projectLocationCollectionDataStoreSessionName( - string $project, - string $location, - string $collection, - string $dataStore, - string $session - ): string { + public static function projectLocationCollectionDataStoreSessionName(string $project, string $location, string $collection, string $dataStore, string $session): string + { return self::getPathTemplate('projectLocationCollectionDataStoreSession')->render([ 'project' => $project, 'location' => $location, @@ -445,14 +395,8 @@ public static function projectLocationCollectionDataStoreSessionName( * * @return string The formatted project_location_collection_data_store_session_answer resource. */ - public static function projectLocationCollectionDataStoreSessionAnswerName( - string $project, - string $location, - string $collection, - string $dataStore, - string $session, - string $answer - ): string { + public static function projectLocationCollectionDataStoreSessionAnswerName(string $project, string $location, string $collection, string $dataStore, string $session, string $answer): string + { return self::getPathTemplate('projectLocationCollectionDataStoreSessionAnswer')->render([ 'project' => $project, 'location' => $location, @@ -475,13 +419,8 @@ public static function projectLocationCollectionDataStoreSessionAnswerName( * * @return string The formatted project_location_collection_engine_conversation resource. */ - public static function projectLocationCollectionEngineConversationName( - string $project, - string $location, - string $collection, - string $engine, - string $conversation - ): string { + public static function projectLocationCollectionEngineConversationName(string $project, string $location, string $collection, string $engine, string $conversation): string + { return self::getPathTemplate('projectLocationCollectionEngineConversation')->render([ 'project' => $project, 'location' => $location, @@ -503,13 +442,8 @@ public static function projectLocationCollectionEngineConversationName( * * @return string The formatted project_location_collection_engine_serving_config resource. */ - public static function projectLocationCollectionEngineServingConfigName( - string $project, - string $location, - string $collection, - string $engine, - string $servingConfig - ): string { + public static function projectLocationCollectionEngineServingConfigName(string $project, string $location, string $collection, string $engine, string $servingConfig): string + { return self::getPathTemplate('projectLocationCollectionEngineServingConfig')->render([ 'project' => $project, 'location' => $location, @@ -531,13 +465,8 @@ public static function projectLocationCollectionEngineServingConfigName( * * @return string The formatted project_location_collection_engine_session resource. */ - public static function projectLocationCollectionEngineSessionName( - string $project, - string $location, - string $collection, - string $engine, - string $session - ): string { + public static function projectLocationCollectionEngineSessionName(string $project, string $location, string $collection, string $engine, string $session): string + { return self::getPathTemplate('projectLocationCollectionEngineSession')->render([ 'project' => $project, 'location' => $location, @@ -560,14 +489,8 @@ public static function projectLocationCollectionEngineSessionName( * * @return string The formatted project_location_collection_engine_session_answer resource. */ - public static function projectLocationCollectionEngineSessionAnswerName( - string $project, - string $location, - string $collection, - string $engine, - string $session, - string $answer - ): string { + public static function projectLocationCollectionEngineSessionAnswerName(string $project, string $location, string $collection, string $engine, string $session, string $answer): string + { return self::getPathTemplate('projectLocationCollectionEngineSessionAnswer')->render([ 'project' => $project, 'location' => $location, @@ -609,13 +532,8 @@ public static function projectLocationDataStoreName(string $project, string $loc * * @return string The formatted project_location_data_store_branch_document resource. */ - public static function projectLocationDataStoreBranchDocumentName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document - ): string { + public static function projectLocationDataStoreBranchDocumentName(string $project, string $location, string $dataStore, string $branch, string $document): string + { return self::getPathTemplate('projectLocationDataStoreBranchDocument')->render([ 'project' => $project, 'location' => $location, @@ -638,14 +556,8 @@ public static function projectLocationDataStoreBranchDocumentName( * * @return string The formatted project_location_data_store_branch_document_chunk resource. */ - public static function projectLocationDataStoreBranchDocumentChunkName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document, - string $chunk - ): string { + public static function projectLocationDataStoreBranchDocumentChunkName(string $project, string $location, string $dataStore, string $branch, string $document, string $chunk): string + { return self::getPathTemplate('projectLocationDataStoreBranchDocumentChunk')->render([ 'project' => $project, 'location' => $location, @@ -667,12 +579,8 @@ public static function projectLocationDataStoreBranchDocumentChunkName( * * @return string The formatted project_location_data_store_conversation resource. */ - public static function projectLocationDataStoreConversationName( - string $project, - string $location, - string $dataStore, - string $conversation - ): string { + public static function projectLocationDataStoreConversationName(string $project, string $location, string $dataStore, string $conversation): string + { return self::getPathTemplate('projectLocationDataStoreConversation')->render([ 'project' => $project, 'location' => $location, @@ -692,12 +600,8 @@ public static function projectLocationDataStoreConversationName( * * @return string The formatted project_location_data_store_serving_config resource. */ - public static function projectLocationDataStoreServingConfigName( - string $project, - string $location, - string $dataStore, - string $servingConfig - ): string { + public static function projectLocationDataStoreServingConfigName(string $project, string $location, string $dataStore, string $servingConfig): string + { return self::getPathTemplate('projectLocationDataStoreServingConfig')->render([ 'project' => $project, 'location' => $location, @@ -717,12 +621,8 @@ public static function projectLocationDataStoreServingConfigName( * * @return string The formatted project_location_data_store_session resource. */ - public static function projectLocationDataStoreSessionName( - string $project, - string $location, - string $dataStore, - string $session - ): string { + public static function projectLocationDataStoreSessionName(string $project, string $location, string $dataStore, string $session): string + { return self::getPathTemplate('projectLocationDataStoreSession')->render([ 'project' => $project, 'location' => $location, @@ -743,13 +643,8 @@ public static function projectLocationDataStoreSessionName( * * @return string The formatted project_location_data_store_session_answer resource. */ - public static function projectLocationDataStoreSessionAnswerName( - string $project, - string $location, - string $dataStore, - string $session, - string $answer - ): string { + public static function projectLocationDataStoreSessionAnswerName(string $project, string $location, string $dataStore, string $session, string $answer): string + { return self::getPathTemplate('projectLocationDataStoreSessionAnswer')->render([ 'project' => $project, 'location' => $location, @@ -770,12 +665,8 @@ public static function projectLocationDataStoreSessionAnswerName( * * @return string The formatted serving_config resource. */ - public static function servingConfigName( - string $project, - string $location, - string $dataStore, - string $servingConfig - ): string { + public static function servingConfigName(string $project, string $location, string $dataStore, string $servingConfig): string + { return self::getPathTemplate('servingConfig')->render([ 'project' => $project, 'location' => $location, @@ -856,25 +747,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'discoveryengine.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DiscoveryEngine\V1\ConversationalSearchServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new ConversationalSearchServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -912,11 +806,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -982,10 +878,8 @@ public function answerQuery(AnswerQueryRequest $request, array $callOptions = [] * * @throws ApiException Thrown if the API call fails. */ - public function converseConversation( - ConverseConversationRequest $request, - array $callOptions = [] - ): ConverseConversationResponse { + public function converseConversation(ConverseConversationRequest $request, array $callOptions = []): ConverseConversationResponse + { return $this->startApiCall('ConverseConversation', $request, $callOptions)->wait(); } @@ -1261,7 +1155,7 @@ public function listSessions(ListSessionsRequest $request, array $callOptions = * Timeout to use for this call. * } * - * @return ServerStream + * @return ServerStream * * @throws ApiException Thrown if the API call fails. */ diff --git a/DiscoveryEngine/src/V1/Client/DataStoreServiceClient.php b/DiscoveryEngine/src/V1/Client/DataStoreServiceClient.php index 59a96f0c9e3f..2203bd606ece 100644 --- a/DiscoveryEngine/src/V1/Client/DataStoreServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/DataStoreServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -88,7 +89,9 @@ final class DataStoreServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -134,9 +137,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -209,13 +210,8 @@ public static function collectionName(string $project, string $location, string * * @return string The formatted crypto_key_versions resource. */ - public static function cryptoKeyVersionsName( - string $project, - string $location, - string $keyRing, - string $cryptoKey, - string $cryptoKeyVersion - ): string { + public static function cryptoKeyVersionsName(string $project, string $location, string $keyRing, string $cryptoKey, string $cryptoKeyVersion): string + { return self::getPathTemplate('cryptoKeyVersions')->render([ 'project' => $project, 'location' => $location, @@ -294,11 +290,8 @@ public static function documentProcessingConfigName(string $project, string $loc * * @return string The formatted identity_mapping_store resource. */ - public static function identityMappingStoreName( - string $project, - string $location, - string $identityMappingStore - ): string { + public static function identityMappingStoreName(string $project, string $location, string $identityMappingStore): string + { return self::getPathTemplate('identityMappingStore')->render([ 'project' => $project, 'location' => $location, @@ -334,12 +327,8 @@ public static function projectLocationCmekConfigName(string $project, string $lo * * @return string The formatted project_location_collection_data_store resource. */ - public static function projectLocationCollectionDataStoreName( - string $project, - string $location, - string $collection, - string $dataStore - ): string { + public static function projectLocationCollectionDataStoreName(string $project, string $location, string $collection, string $dataStore): string + { return self::getPathTemplate('projectLocationCollectionDataStore')->render([ 'project' => $project, 'location' => $location, @@ -359,12 +348,8 @@ public static function projectLocationCollectionDataStoreName( * * @return string The formatted project_location_collection_data_store_documentProcessingConfig resource. */ - public static function projectLocationCollectionDataStoreDocumentProcessingConfigName( - string $project, - string $location, - string $collection, - string $dataStore - ): string { + public static function projectLocationCollectionDataStoreDocumentProcessingConfigName(string $project, string $location, string $collection, string $dataStore): string + { return self::getPathTemplate('projectLocationCollectionDataStoreDocumentProcessingConfig')->render([ 'project' => $project, 'location' => $location, @@ -385,13 +370,8 @@ public static function projectLocationCollectionDataStoreDocumentProcessingConfi * * @return string The formatted project_location_collection_data_store_schema resource. */ - public static function projectLocationCollectionDataStoreSchemaName( - string $project, - string $location, - string $collection, - string $dataStore, - string $schema - ): string { + public static function projectLocationCollectionDataStoreSchemaName(string $project, string $location, string $collection, string $dataStore, string $schema): string + { return self::getPathTemplate('projectLocationCollectionDataStoreSchema')->render([ 'project' => $project, 'location' => $location, @@ -430,11 +410,8 @@ public static function projectLocationDataStoreName(string $project, string $loc * * @return string The formatted project_location_data_store_documentProcessingConfig resource. */ - public static function projectLocationDataStoreDocumentProcessingConfigName( - string $project, - string $location, - string $dataStore - ): string { + public static function projectLocationDataStoreDocumentProcessingConfigName(string $project, string $location, string $dataStore): string + { return self::getPathTemplate('projectLocationDataStoreDocumentProcessingConfig')->render([ 'project' => $project, 'location' => $location, @@ -453,12 +430,8 @@ public static function projectLocationDataStoreDocumentProcessingConfigName( * * @return string The formatted project_location_data_store_schema resource. */ - public static function projectLocationDataStoreSchemaName( - string $project, - string $location, - string $dataStore, - string $schema - ): string { + public static function projectLocationDataStoreSchemaName(string $project, string $location, string $dataStore, string $schema): string + { return self::getPathTemplate('projectLocationDataStoreSchema')->render([ 'project' => $project, 'location' => $location, @@ -529,25 +502,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'discoveryengine.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DiscoveryEngine\V1\DataStoreServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new DataStoreServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -585,11 +561,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -630,7 +608,7 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -656,7 +634,7 @@ public function createDataStore(CreateDataStoreRequest $request, array $callOpti * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ diff --git a/DiscoveryEngine/src/V1/Client/DocumentServiceClient.php b/DiscoveryEngine/src/V1/Client/DocumentServiceClient.php index 655207bf0b38..4ad36dfdfca6 100644 --- a/DiscoveryEngine/src/V1/Client/DocumentServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/DocumentServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -41,8 +42,10 @@ use Google\Cloud\DiscoveryEngine\V1\Document; use Google\Cloud\DiscoveryEngine\V1\GetDocumentRequest; use Google\Cloud\DiscoveryEngine\V1\ImportDocumentsRequest; +use Google\Cloud\DiscoveryEngine\V1\ImportDocumentsResponse; use Google\Cloud\DiscoveryEngine\V1\ListDocumentsRequest; use Google\Cloud\DiscoveryEngine\V1\PurgeDocumentsRequest; +use Google\Cloud\DiscoveryEngine\V1\PurgeDocumentsResponse; use Google\Cloud\DiscoveryEngine\V1\UpdateDocumentRequest; use Google\LongRunning\Client\OperationsClient; use Google\LongRunning\Operation; @@ -95,7 +98,9 @@ final class DocumentServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -141,9 +146,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -201,13 +204,8 @@ public static function branchName(string $project, string $location, string $dat * * @return string The formatted document resource. */ - public static function documentName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document - ): string { + public static function documentName(string $project, string $location, string $dataStore, string $branch, string $document): string + { return self::getPathTemplate('document')->render([ 'project' => $project, 'location' => $location, @@ -230,14 +228,8 @@ public static function documentName( * * @return string The formatted fhir_resource resource. */ - public static function fhirResourceName( - string $project, - string $location, - string $dataset, - string $fhirStore, - string $resourceType, - string $fhirResourceId - ): string { + public static function fhirResourceName(string $project, string $location, string $dataset, string $fhirStore, string $resourceType, string $fhirResourceId): string + { return self::getPathTemplate('fhirResource')->render([ 'project' => $project, 'location' => $location, @@ -281,13 +273,8 @@ public static function fhirStoreName(string $project, string $location, string $ * * @return string The formatted project_location_collection_data_store_branch resource. */ - public static function projectLocationCollectionDataStoreBranchName( - string $project, - string $location, - string $collection, - string $dataStore, - string $branch - ): string { + public static function projectLocationCollectionDataStoreBranchName(string $project, string $location, string $collection, string $dataStore, string $branch): string + { return self::getPathTemplate('projectLocationCollectionDataStoreBranch')->render([ 'project' => $project, 'location' => $location, @@ -310,14 +297,8 @@ public static function projectLocationCollectionDataStoreBranchName( * * @return string The formatted project_location_collection_data_store_branch_document resource. */ - public static function projectLocationCollectionDataStoreBranchDocumentName( - string $project, - string $location, - string $collection, - string $dataStore, - string $branch, - string $document - ): string { + public static function projectLocationCollectionDataStoreBranchDocumentName(string $project, string $location, string $collection, string $dataStore, string $branch, string $document): string + { return self::getPathTemplate('projectLocationCollectionDataStoreBranchDocument')->render([ 'project' => $project, 'location' => $location, @@ -339,12 +320,8 @@ public static function projectLocationCollectionDataStoreBranchDocumentName( * * @return string The formatted project_location_data_store_branch resource. */ - public static function projectLocationDataStoreBranchName( - string $project, - string $location, - string $dataStore, - string $branch - ): string { + public static function projectLocationDataStoreBranchName(string $project, string $location, string $dataStore, string $branch): string + { return self::getPathTemplate('projectLocationDataStoreBranch')->render([ 'project' => $project, 'location' => $location, @@ -365,13 +342,8 @@ public static function projectLocationDataStoreBranchName( * * @return string The formatted project_location_data_store_branch_document resource. */ - public static function projectLocationDataStoreBranchDocumentName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document - ): string { + public static function projectLocationDataStoreBranchDocumentName(string $project, string $location, string $dataStore, string $branch, string $document): string + { return self::getPathTemplate('projectLocationDataStoreBranchDocument')->render([ 'project' => $project, 'location' => $location, @@ -415,25 +387,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'discoveryengine.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DiscoveryEngine\V1\DocumentServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new DocumentServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -471,11 +446,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -517,10 +494,8 @@ public function __call($method, $args) * * @throws ApiException Thrown if the API call fails. */ - public function batchGetDocumentsMetadata( - BatchGetDocumentsMetadataRequest $request, - array $callOptions = [] - ): BatchGetDocumentsMetadataResponse { + public function batchGetDocumentsMetadata(BatchGetDocumentsMetadataRequest $request, array $callOptions = []): BatchGetDocumentsMetadataResponse + { return $this->startApiCall('BatchGetDocumentsMetadata', $request, $callOptions)->wait(); } @@ -623,7 +598,7 @@ public function getDocument(GetDocumentRequest $request, array $callOptions = [] * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -690,7 +665,7 @@ public function listDocuments(ListDocumentsRequest $request, array $callOptions * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ diff --git a/DiscoveryEngine/src/V1/Client/EngineServiceClient.php b/DiscoveryEngine/src/V1/Client/EngineServiceClient.php index 2f0c6ed10c58..a75479eb42fb 100644 --- a/DiscoveryEngine/src/V1/Client/EngineServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/EngineServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -88,7 +89,9 @@ final class EngineServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -134,9 +137,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -229,25 +230,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'discoveryengine.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DiscoveryEngine\V1\EngineServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new EngineServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -285,11 +289,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -324,7 +330,7 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -350,7 +356,7 @@ public function createEngine(CreateEngineRequest $request, array $callOptions = * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ diff --git a/DiscoveryEngine/src/V1/Client/GroundedGenerationServiceClient.php b/DiscoveryEngine/src/V1/Client/GroundedGenerationServiceClient.php index 92666b943f80..64aa9af6902d 100644 --- a/DiscoveryEngine/src/V1/Client/GroundedGenerationServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/GroundedGenerationServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\BidiStream; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; @@ -79,7 +80,9 @@ final class GroundedGenerationServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private static function getClientDefaults() { @@ -94,8 +97,7 @@ private static function getClientDefaults() ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => - __DIR__ . '/../resources/grounded_generation_service_rest_client_config.php', + 'restClientConfigPath' => __DIR__ . '/../resources/grounded_generation_service_rest_client_config.php', ], ], ]; @@ -149,13 +151,8 @@ public static function locationName(string $project, string $location): string * * @return string The formatted project_location_collection_data_store_serving_config resource. */ - public static function projectLocationCollectionDataStoreServingConfigName( - string $project, - string $location, - string $collection, - string $dataStore, - string $servingConfig - ): string { + public static function projectLocationCollectionDataStoreServingConfigName(string $project, string $location, string $collection, string $dataStore, string $servingConfig): string + { return self::getPathTemplate('projectLocationCollectionDataStoreServingConfig')->render([ 'project' => $project, 'location' => $location, @@ -177,13 +174,8 @@ public static function projectLocationCollectionDataStoreServingConfigName( * * @return string The formatted project_location_collection_engine_serving_config resource. */ - public static function projectLocationCollectionEngineServingConfigName( - string $project, - string $location, - string $collection, - string $engine, - string $servingConfig - ): string { + public static function projectLocationCollectionEngineServingConfigName(string $project, string $location, string $collection, string $engine, string $servingConfig): string + { return self::getPathTemplate('projectLocationCollectionEngineServingConfig')->render([ 'project' => $project, 'location' => $location, @@ -204,12 +196,8 @@ public static function projectLocationCollectionEngineServingConfigName( * * @return string The formatted project_location_data_store_serving_config resource. */ - public static function projectLocationDataStoreServingConfigName( - string $project, - string $location, - string $dataStore, - string $servingConfig - ): string { + public static function projectLocationDataStoreServingConfigName(string $project, string $location, string $dataStore, string $servingConfig): string + { return self::getPathTemplate('projectLocationDataStoreServingConfig')->render([ 'project' => $project, 'location' => $location, @@ -229,12 +217,8 @@ public static function projectLocationDataStoreServingConfigName( * * @return string The formatted serving_config resource. */ - public static function servingConfigName( - string $project, - string $location, - string $dataStore, - string $servingConfig - ): string { + public static function servingConfigName(string $project, string $location, string $dataStore, string $servingConfig): string + { return self::getPathTemplate('servingConfig')->render([ 'project' => $project, 'location' => $location, @@ -275,25 +259,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'discoveryengine.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DiscoveryEngine\V1\GroundedGenerationServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new GroundedGenerationServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -331,11 +318,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -401,10 +390,8 @@ public function checkGrounding(CheckGroundingRequest $request, array $callOption * * @throws ApiException Thrown if the API call fails. */ - public function generateGroundedContent( - GenerateGroundedContentRequest $request, - array $callOptions = [] - ): GenerateGroundedContentResponse { + public function generateGroundedContent(GenerateGroundedContentRequest $request, array $callOptions = []): GenerateGroundedContentResponse + { return $this->startApiCall('GenerateGroundedContent', $request, $callOptions)->wait(); } diff --git a/DiscoveryEngine/src/V1/Client/IdentityMappingStoreServiceClient.php b/DiscoveryEngine/src/V1/Client/IdentityMappingStoreServiceClient.php index 8d5ca3929ed0..b959aff45221 100644 --- a/DiscoveryEngine/src/V1/Client/IdentityMappingStoreServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/IdentityMappingStoreServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -39,6 +40,7 @@ use Google\Cloud\DiscoveryEngine\V1\GetIdentityMappingStoreRequest; use Google\Cloud\DiscoveryEngine\V1\IdentityMappingStore; use Google\Cloud\DiscoveryEngine\V1\ImportIdentityMappingsRequest; +use Google\Cloud\DiscoveryEngine\V1\ImportIdentityMappingsResponse; use Google\Cloud\DiscoveryEngine\V1\ListIdentityMappingStoresRequest; use Google\Cloud\DiscoveryEngine\V1\ListIdentityMappingsRequest; use Google\Cloud\DiscoveryEngine\V1\PurgeIdentityMappingsRequest; @@ -91,7 +93,9 @@ final class IdentityMappingStoreServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -108,8 +112,7 @@ private static function getClientDefaults() ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => - __DIR__ . '/../resources/identity_mapping_store_service_rest_client_config.php', + 'restClientConfigPath' => __DIR__ . '/../resources/identity_mapping_store_service_rest_client_config.php', ], ], ]; @@ -138,9 +141,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -194,13 +195,8 @@ public static function cmekConfigName(string $project, string $location): string * * @return string The formatted crypto_key_versions resource. */ - public static function cryptoKeyVersionsName( - string $project, - string $location, - string $keyRing, - string $cryptoKey, - string $cryptoKeyVersion - ): string { + public static function cryptoKeyVersionsName(string $project, string $location, string $keyRing, string $cryptoKey, string $cryptoKeyVersion): string + { return self::getPathTemplate('cryptoKeyVersions')->render([ 'project' => $project, 'location' => $location, @@ -241,11 +237,8 @@ public static function cryptoKeysName(string $project, string $location, string * * @return string The formatted identity_mapping_store resource. */ - public static function identityMappingStoreName( - string $project, - string $location, - string $identityMappingStore - ): string { + public static function identityMappingStoreName(string $project, string $location, string $identityMappingStore): string + { return self::getPathTemplate('identityMappingStore')->render([ 'project' => $project, 'location' => $location, @@ -319,25 +312,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'discoveryengine.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DiscoveryEngine\V1\IdentityMappingStoreServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new IdentityMappingStoreServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -375,11 +371,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -419,10 +417,8 @@ public function __call($method, $args) * * @throws ApiException Thrown if the API call fails. */ - public function createIdentityMappingStore( - CreateIdentityMappingStoreRequest $request, - array $callOptions = [] - ): IdentityMappingStore { + public function createIdentityMappingStore(CreateIdentityMappingStoreRequest $request, array $callOptions = []): IdentityMappingStore + { return $this->startApiCall('CreateIdentityMappingStore', $request, $callOptions)->wait(); } @@ -444,14 +440,12 @@ public function createIdentityMappingStore( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function deleteIdentityMappingStore( - DeleteIdentityMappingStoreRequest $request, - array $callOptions = [] - ): OperationResponse { + public function deleteIdentityMappingStore(DeleteIdentityMappingStoreRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('DeleteIdentityMappingStore', $request, $callOptions)->wait(); } @@ -477,10 +471,8 @@ public function deleteIdentityMappingStore( * * @throws ApiException Thrown if the API call fails. */ - public function getIdentityMappingStore( - GetIdentityMappingStoreRequest $request, - array $callOptions = [] - ): IdentityMappingStore { + public function getIdentityMappingStore(GetIdentityMappingStoreRequest $request, array $callOptions = []): IdentityMappingStore + { return $this->startApiCall('GetIdentityMappingStore', $request, $callOptions)->wait(); } @@ -502,14 +494,12 @@ public function getIdentityMappingStore( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function importIdentityMappings( - ImportIdentityMappingsRequest $request, - array $callOptions = [] - ): OperationResponse { + public function importIdentityMappings(ImportIdentityMappingsRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('ImportIdentityMappings', $request, $callOptions)->wait(); } @@ -535,10 +525,8 @@ public function importIdentityMappings( * * @throws ApiException Thrown if the API call fails. */ - public function listIdentityMappingStores( - ListIdentityMappingStoresRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listIdentityMappingStores(ListIdentityMappingStoresRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListIdentityMappingStores', $request, $callOptions); } @@ -564,10 +552,8 @@ public function listIdentityMappingStores( * * @throws ApiException Thrown if the API call fails. */ - public function listIdentityMappings( - ListIdentityMappingsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listIdentityMappings(ListIdentityMappingsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListIdentityMappings', $request, $callOptions); } @@ -590,14 +576,12 @@ public function listIdentityMappings( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function purgeIdentityMappings( - PurgeIdentityMappingsRequest $request, - array $callOptions = [] - ): OperationResponse { + public function purgeIdentityMappings(PurgeIdentityMappingsRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('PurgeIdentityMappings', $request, $callOptions)->wait(); } } diff --git a/DiscoveryEngine/src/V1/Client/ProjectServiceClient.php b/DiscoveryEngine/src/V1/Client/ProjectServiceClient.php index 6a493b4b865a..a3bb3ab7fa53 100644 --- a/DiscoveryEngine/src/V1/Client/ProjectServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/ProjectServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; @@ -79,7 +80,9 @@ final class ProjectServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -125,9 +128,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -194,25 +195,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'discoveryengine.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DiscoveryEngine\V1\ProjectServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new ProjectServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -250,11 +254,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -294,7 +300,7 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ diff --git a/DiscoveryEngine/src/V1/Client/RankServiceClient.php b/DiscoveryEngine/src/V1/Client/RankServiceClient.php index ee33105dbda1..101158101718 100644 --- a/DiscoveryEngine/src/V1/Client/RankServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/RankServiceClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; @@ -75,7 +76,9 @@ final class RankServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private static function getClientDefaults() { @@ -142,25 +145,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'discoveryengine.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DiscoveryEngine\V1\RankServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new RankServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -198,11 +204,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/DiscoveryEngine/src/V1/Client/RecommendationServiceClient.php b/DiscoveryEngine/src/V1/Client/RecommendationServiceClient.php index 9d40efd741af..e1bfba9c8259 100644 --- a/DiscoveryEngine/src/V1/Client/RecommendationServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/RecommendationServiceClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; @@ -75,7 +76,9 @@ final class RecommendationServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private static function getClientDefaults() { @@ -127,13 +130,8 @@ public static function dataStoreName(string $project, string $location, string $ * * @return string The formatted document resource. */ - public static function documentName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document - ): string { + public static function documentName(string $project, string $location, string $dataStore, string $branch, string $document): string + { return self::getPathTemplate('document')->render([ 'project' => $project, 'location' => $location, @@ -175,12 +173,8 @@ public static function engineName(string $project, string $location, string $col * * @return string The formatted project_location_collection_data_store resource. */ - public static function projectLocationCollectionDataStoreName( - string $project, - string $location, - string $collection, - string $dataStore - ): string { + public static function projectLocationCollectionDataStoreName(string $project, string $location, string $collection, string $dataStore): string + { return self::getPathTemplate('projectLocationCollectionDataStore')->render([ 'project' => $project, 'location' => $location, @@ -202,14 +196,8 @@ public static function projectLocationCollectionDataStoreName( * * @return string The formatted project_location_collection_data_store_branch_document resource. */ - public static function projectLocationCollectionDataStoreBranchDocumentName( - string $project, - string $location, - string $collection, - string $dataStore, - string $branch, - string $document - ): string { + public static function projectLocationCollectionDataStoreBranchDocumentName(string $project, string $location, string $collection, string $dataStore, string $branch, string $document): string + { return self::getPathTemplate('projectLocationCollectionDataStoreBranchDocument')->render([ 'project' => $project, 'location' => $location, @@ -232,13 +220,8 @@ public static function projectLocationCollectionDataStoreBranchDocumentName( * * @return string The formatted project_location_collection_data_store_serving_config resource. */ - public static function projectLocationCollectionDataStoreServingConfigName( - string $project, - string $location, - string $collection, - string $dataStore, - string $servingConfig - ): string { + public static function projectLocationCollectionDataStoreServingConfigName(string $project, string $location, string $collection, string $dataStore, string $servingConfig): string + { return self::getPathTemplate('projectLocationCollectionDataStoreServingConfig')->render([ 'project' => $project, 'location' => $location, @@ -260,13 +243,8 @@ public static function projectLocationCollectionDataStoreServingConfigName( * * @return string The formatted project_location_collection_engine_serving_config resource. */ - public static function projectLocationCollectionEngineServingConfigName( - string $project, - string $location, - string $collection, - string $engine, - string $servingConfig - ): string { + public static function projectLocationCollectionEngineServingConfigName(string $project, string $location, string $collection, string $engine, string $servingConfig): string + { return self::getPathTemplate('projectLocationCollectionEngineServingConfig')->render([ 'project' => $project, 'location' => $location, @@ -307,13 +285,8 @@ public static function projectLocationDataStoreName(string $project, string $loc * * @return string The formatted project_location_data_store_branch_document resource. */ - public static function projectLocationDataStoreBranchDocumentName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document - ): string { + public static function projectLocationDataStoreBranchDocumentName(string $project, string $location, string $dataStore, string $branch, string $document): string + { return self::getPathTemplate('projectLocationDataStoreBranchDocument')->render([ 'project' => $project, 'location' => $location, @@ -334,12 +307,8 @@ public static function projectLocationDataStoreBranchDocumentName( * * @return string The formatted project_location_data_store_serving_config resource. */ - public static function projectLocationDataStoreServingConfigName( - string $project, - string $location, - string $dataStore, - string $servingConfig - ): string { + public static function projectLocationDataStoreServingConfigName(string $project, string $location, string $dataStore, string $servingConfig): string + { return self::getPathTemplate('projectLocationDataStoreServingConfig')->render([ 'project' => $project, 'location' => $location, @@ -359,12 +328,8 @@ public static function projectLocationDataStoreServingConfigName( * * @return string The formatted serving_config resource. */ - public static function servingConfigName( - string $project, - string $location, - string $dataStore, - string $servingConfig - ): string { + public static function servingConfigName(string $project, string $location, string $dataStore, string $servingConfig): string + { return self::getPathTemplate('servingConfig')->render([ 'project' => $project, 'location' => $location, @@ -410,25 +375,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'discoveryengine.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DiscoveryEngine\V1\RecommendationServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new RecommendationServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -466,11 +434,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/DiscoveryEngine/src/V1/Client/SchemaServiceClient.php b/DiscoveryEngine/src/V1/Client/SchemaServiceClient.php index d1866d9f94cd..065fa1873680 100644 --- a/DiscoveryEngine/src/V1/Client/SchemaServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/SchemaServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -87,7 +88,9 @@ final class SchemaServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -133,9 +136,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -190,12 +191,8 @@ public static function dataStoreName(string $project, string $location, string $ * * @return string The formatted project_location_collection_data_store resource. */ - public static function projectLocationCollectionDataStoreName( - string $project, - string $location, - string $collection, - string $dataStore - ): string { + public static function projectLocationCollectionDataStoreName(string $project, string $location, string $collection, string $dataStore): string + { return self::getPathTemplate('projectLocationCollectionDataStore')->render([ 'project' => $project, 'location' => $location, @@ -216,13 +213,8 @@ public static function projectLocationCollectionDataStoreName( * * @return string The formatted project_location_collection_data_store_schema resource. */ - public static function projectLocationCollectionDataStoreSchemaName( - string $project, - string $location, - string $collection, - string $dataStore, - string $schema - ): string { + public static function projectLocationCollectionDataStoreSchemaName(string $project, string $location, string $collection, string $dataStore, string $schema): string + { return self::getPathTemplate('projectLocationCollectionDataStoreSchema')->render([ 'project' => $project, 'location' => $location, @@ -262,12 +254,8 @@ public static function projectLocationDataStoreName(string $project, string $loc * * @return string The formatted project_location_data_store_schema resource. */ - public static function projectLocationDataStoreSchemaName( - string $project, - string $location, - string $dataStore, - string $schema - ): string { + public static function projectLocationDataStoreSchemaName(string $project, string $location, string $dataStore, string $schema): string + { return self::getPathTemplate('projectLocationDataStoreSchema')->render([ 'project' => $project, 'location' => $location, @@ -329,25 +317,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'discoveryengine.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DiscoveryEngine\V1\SchemaServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new SchemaServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -385,11 +376,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -424,7 +417,7 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -450,7 +443,7 @@ public function createSchema(CreateSchemaRequest $request, array $callOptions = * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -528,7 +521,7 @@ public function listSchemas(ListSchemasRequest $request, array $callOptions = [] * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ diff --git a/DiscoveryEngine/src/V1/Client/SearchServiceClient.php b/DiscoveryEngine/src/V1/Client/SearchServiceClient.php index e4a65ccec62b..acea1aa52968 100644 --- a/DiscoveryEngine/src/V1/Client/SearchServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/SearchServiceClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -76,7 +77,9 @@ final class SearchServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private static function getClientDefaults() { @@ -148,12 +151,8 @@ public static function dataStoreName(string $project, string $location, string $ * * @return string The formatted project_location_collection_data_store resource. */ - public static function projectLocationCollectionDataStoreName( - string $project, - string $location, - string $collection, - string $dataStore - ): string { + public static function projectLocationCollectionDataStoreName(string $project, string $location, string $collection, string $dataStore): string + { return self::getPathTemplate('projectLocationCollectionDataStore')->render([ 'project' => $project, 'location' => $location, @@ -174,13 +173,8 @@ public static function projectLocationCollectionDataStoreName( * * @return string The formatted project_location_collection_data_store_branch resource. */ - public static function projectLocationCollectionDataStoreBranchName( - string $project, - string $location, - string $collection, - string $dataStore, - string $branch - ): string { + public static function projectLocationCollectionDataStoreBranchName(string $project, string $location, string $collection, string $dataStore, string $branch): string + { return self::getPathTemplate('projectLocationCollectionDataStoreBranch')->render([ 'project' => $project, 'location' => $location, @@ -202,13 +196,8 @@ public static function projectLocationCollectionDataStoreBranchName( * * @return string The formatted project_location_collection_data_store_serving_config resource. */ - public static function projectLocationCollectionDataStoreServingConfigName( - string $project, - string $location, - string $collection, - string $dataStore, - string $servingConfig - ): string { + public static function projectLocationCollectionDataStoreServingConfigName(string $project, string $location, string $collection, string $dataStore, string $servingConfig): string + { return self::getPathTemplate('projectLocationCollectionDataStoreServingConfig')->render([ 'project' => $project, 'location' => $location, @@ -230,13 +219,8 @@ public static function projectLocationCollectionDataStoreServingConfigName( * * @return string The formatted project_location_collection_data_store_session resource. */ - public static function projectLocationCollectionDataStoreSessionName( - string $project, - string $location, - string $collection, - string $dataStore, - string $session - ): string { + public static function projectLocationCollectionDataStoreSessionName(string $project, string $location, string $collection, string $dataStore, string $session): string + { return self::getPathTemplate('projectLocationCollectionDataStoreSession')->render([ 'project' => $project, 'location' => $location, @@ -258,13 +242,8 @@ public static function projectLocationCollectionDataStoreSessionName( * * @return string The formatted project_location_collection_engine_serving_config resource. */ - public static function projectLocationCollectionEngineServingConfigName( - string $project, - string $location, - string $collection, - string $engine, - string $servingConfig - ): string { + public static function projectLocationCollectionEngineServingConfigName(string $project, string $location, string $collection, string $engine, string $servingConfig): string + { return self::getPathTemplate('projectLocationCollectionEngineServingConfig')->render([ 'project' => $project, 'location' => $location, @@ -286,13 +265,8 @@ public static function projectLocationCollectionEngineServingConfigName( * * @return string The formatted project_location_collection_engine_session resource. */ - public static function projectLocationCollectionEngineSessionName( - string $project, - string $location, - string $collection, - string $engine, - string $session - ): string { + public static function projectLocationCollectionEngineSessionName(string $project, string $location, string $collection, string $engine, string $session): string + { return self::getPathTemplate('projectLocationCollectionEngineSession')->render([ 'project' => $project, 'location' => $location, @@ -332,12 +306,8 @@ public static function projectLocationDataStoreName(string $project, string $loc * * @return string The formatted project_location_data_store_branch resource. */ - public static function projectLocationDataStoreBranchName( - string $project, - string $location, - string $dataStore, - string $branch - ): string { + public static function projectLocationDataStoreBranchName(string $project, string $location, string $dataStore, string $branch): string + { return self::getPathTemplate('projectLocationDataStoreBranch')->render([ 'project' => $project, 'location' => $location, @@ -357,12 +327,8 @@ public static function projectLocationDataStoreBranchName( * * @return string The formatted project_location_data_store_serving_config resource. */ - public static function projectLocationDataStoreServingConfigName( - string $project, - string $location, - string $dataStore, - string $servingConfig - ): string { + public static function projectLocationDataStoreServingConfigName(string $project, string $location, string $dataStore, string $servingConfig): string + { return self::getPathTemplate('projectLocationDataStoreServingConfig')->render([ 'project' => $project, 'location' => $location, @@ -382,12 +348,8 @@ public static function projectLocationDataStoreServingConfigName( * * @return string The formatted project_location_data_store_session resource. */ - public static function projectLocationDataStoreSessionName( - string $project, - string $location, - string $dataStore, - string $session - ): string { + public static function projectLocationDataStoreSessionName(string $project, string $location, string $dataStore, string $session): string + { return self::getPathTemplate('projectLocationDataStoreSession')->render([ 'project' => $project, 'location' => $location, @@ -407,12 +369,8 @@ public static function projectLocationDataStoreSessionName( * * @return string The formatted serving_config resource. */ - public static function servingConfigName( - string $project, - string $location, - string $dataStore, - string $servingConfig - ): string { + public static function servingConfigName(string $project, string $location, string $dataStore, string $servingConfig): string + { return self::getPathTemplate('servingConfig')->render([ 'project' => $project, 'location' => $location, @@ -482,25 +440,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'discoveryengine.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DiscoveryEngine\V1\SearchServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new SearchServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -538,11 +499,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/DiscoveryEngine/src/V1/Client/SearchTuningServiceClient.php b/DiscoveryEngine/src/V1/Client/SearchTuningServiceClient.php index 71dc02f22b78..27d5e5507041 100644 --- a/DiscoveryEngine/src/V1/Client/SearchTuningServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/SearchTuningServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; @@ -36,6 +37,7 @@ use Google\Cloud\DiscoveryEngine\V1\ListCustomModelsRequest; use Google\Cloud\DiscoveryEngine\V1\ListCustomModelsResponse; use Google\Cloud\DiscoveryEngine\V1\TrainCustomModelRequest; +use Google\Cloud\DiscoveryEngine\V1\TrainCustomModelResponse; use Google\LongRunning\Client\OperationsClient; use Google\LongRunning\Operation; use GuzzleHttp\Promise\PromiseInterface; @@ -80,7 +82,9 @@ final class SearchTuningServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -126,9 +130,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -183,12 +185,8 @@ public static function dataStoreName(string $project, string $location, string $ * * @return string The formatted project_location_collection_data_store resource. */ - public static function projectLocationCollectionDataStoreName( - string $project, - string $location, - string $collection, - string $dataStore - ): string { + public static function projectLocationCollectionDataStoreName(string $project, string $location, string $collection, string $dataStore): string + { return self::getPathTemplate('projectLocationCollectionDataStore')->render([ 'project' => $project, 'location' => $location, @@ -245,25 +243,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'discoveryengine.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DiscoveryEngine\V1\SearchTuningServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new SearchTuningServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -301,11 +302,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -344,10 +347,8 @@ public function __call($method, $args) * * @throws ApiException Thrown if the API call fails. */ - public function listCustomModels( - ListCustomModelsRequest $request, - array $callOptions = [] - ): ListCustomModelsResponse { + public function listCustomModels(ListCustomModelsRequest $request, array $callOptions = []): ListCustomModelsResponse + { return $this->startApiCall('ListCustomModels', $request, $callOptions)->wait(); } @@ -368,7 +369,7 @@ public function listCustomModels( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ diff --git a/DiscoveryEngine/src/V1/Client/ServingConfigServiceClient.php b/DiscoveryEngine/src/V1/Client/ServingConfigServiceClient.php index 90ed40dc93e5..6f46e800290b 100644 --- a/DiscoveryEngine/src/V1/Client/ServingConfigServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/ServingConfigServiceClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; @@ -76,7 +77,9 @@ final class ServingConfigServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private static function getClientDefaults() { @@ -109,13 +112,8 @@ private static function getClientDefaults() * * @return string The formatted project_location_collection_data_store_serving_config resource. */ - public static function projectLocationCollectionDataStoreServingConfigName( - string $project, - string $location, - string $collection, - string $dataStore, - string $servingConfig - ): string { + public static function projectLocationCollectionDataStoreServingConfigName(string $project, string $location, string $collection, string $dataStore, string $servingConfig): string + { return self::getPathTemplate('projectLocationCollectionDataStoreServingConfig')->render([ 'project' => $project, 'location' => $location, @@ -137,13 +135,8 @@ public static function projectLocationCollectionDataStoreServingConfigName( * * @return string The formatted project_location_collection_engine_serving_config resource. */ - public static function projectLocationCollectionEngineServingConfigName( - string $project, - string $location, - string $collection, - string $engine, - string $servingConfig - ): string { + public static function projectLocationCollectionEngineServingConfigName(string $project, string $location, string $collection, string $engine, string $servingConfig): string + { return self::getPathTemplate('projectLocationCollectionEngineServingConfig')->render([ 'project' => $project, 'location' => $location, @@ -164,12 +157,8 @@ public static function projectLocationCollectionEngineServingConfigName( * * @return string The formatted project_location_data_store_serving_config resource. */ - public static function projectLocationDataStoreServingConfigName( - string $project, - string $location, - string $dataStore, - string $servingConfig - ): string { + public static function projectLocationDataStoreServingConfigName(string $project, string $location, string $dataStore, string $servingConfig): string + { return self::getPathTemplate('projectLocationDataStoreServingConfig')->render([ 'project' => $project, 'location' => $location, @@ -189,12 +178,8 @@ public static function projectLocationDataStoreServingConfigName( * * @return string The formatted serving_config resource. */ - public static function servingConfigName( - string $project, - string $location, - string $dataStore, - string $servingConfig - ): string { + public static function servingConfigName(string $project, string $location, string $dataStore, string $servingConfig): string + { return self::getPathTemplate('servingConfig')->render([ 'project' => $project, 'location' => $location, @@ -233,25 +218,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'discoveryengine.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DiscoveryEngine\V1\ServingConfigServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new ServingConfigServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -289,11 +277,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/DiscoveryEngine/src/V1/Client/SessionServiceClient.php b/DiscoveryEngine/src/V1/Client/SessionServiceClient.php index 12c7f4a4f9a4..c2fc33e89179 100644 --- a/DiscoveryEngine/src/V1/Client/SessionServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/SessionServiceClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -84,7 +85,9 @@ final class SessionServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private static function getClientDefaults() { @@ -117,13 +120,8 @@ private static function getClientDefaults() * * @return string The formatted answer resource. */ - public static function answerName( - string $project, - string $location, - string $dataStore, - string $session, - string $answer - ): string { + public static function answerName(string $project, string $location, string $dataStore, string $session, string $answer): string + { return self::getPathTemplate('answer')->render([ 'project' => $project, 'location' => $location, @@ -146,14 +144,8 @@ public static function answerName( * * @return string The formatted chunk resource. */ - public static function chunkName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document, - string $chunk - ): string { + public static function chunkName(string $project, string $location, string $dataStore, string $branch, string $document, string $chunk): string + { return self::getPathTemplate('chunk')->render([ 'project' => $project, 'location' => $location, @@ -195,13 +187,8 @@ public static function dataStoreName(string $project, string $location, string $ * * @return string The formatted document resource. */ - public static function documentName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document - ): string { + public static function documentName(string $project, string $location, string $dataStore, string $branch, string $document): string + { return self::getPathTemplate('document')->render([ 'project' => $project, 'location' => $location, @@ -222,12 +209,8 @@ public static function documentName( * * @return string The formatted project_location_collection_data_store resource. */ - public static function projectLocationCollectionDataStoreName( - string $project, - string $location, - string $collection, - string $dataStore - ): string { + public static function projectLocationCollectionDataStoreName(string $project, string $location, string $collection, string $dataStore): string + { return self::getPathTemplate('projectLocationCollectionDataStore')->render([ 'project' => $project, 'location' => $location, @@ -249,14 +232,8 @@ public static function projectLocationCollectionDataStoreName( * * @return string The formatted project_location_collection_data_store_branch_document resource. */ - public static function projectLocationCollectionDataStoreBranchDocumentName( - string $project, - string $location, - string $collection, - string $dataStore, - string $branch, - string $document - ): string { + public static function projectLocationCollectionDataStoreBranchDocumentName(string $project, string $location, string $collection, string $dataStore, string $branch, string $document): string + { return self::getPathTemplate('projectLocationCollectionDataStoreBranchDocument')->render([ 'project' => $project, 'location' => $location, @@ -281,15 +258,8 @@ public static function projectLocationCollectionDataStoreBranchDocumentName( * * @return string The formatted project_location_collection_data_store_branch_document_chunk resource. */ - public static function projectLocationCollectionDataStoreBranchDocumentChunkName( - string $project, - string $location, - string $collection, - string $dataStore, - string $branch, - string $document, - string $chunk - ): string { + public static function projectLocationCollectionDataStoreBranchDocumentChunkName(string $project, string $location, string $collection, string $dataStore, string $branch, string $document, string $chunk): string + { return self::getPathTemplate('projectLocationCollectionDataStoreBranchDocumentChunk')->render([ 'project' => $project, 'location' => $location, @@ -313,13 +283,8 @@ public static function projectLocationCollectionDataStoreBranchDocumentChunkName * * @return string The formatted project_location_collection_data_store_session resource. */ - public static function projectLocationCollectionDataStoreSessionName( - string $project, - string $location, - string $collection, - string $dataStore, - string $session - ): string { + public static function projectLocationCollectionDataStoreSessionName(string $project, string $location, string $collection, string $dataStore, string $session): string + { return self::getPathTemplate('projectLocationCollectionDataStoreSession')->render([ 'project' => $project, 'location' => $location, @@ -342,14 +307,8 @@ public static function projectLocationCollectionDataStoreSessionName( * * @return string The formatted project_location_collection_data_store_session_answer resource. */ - public static function projectLocationCollectionDataStoreSessionAnswerName( - string $project, - string $location, - string $collection, - string $dataStore, - string $session, - string $answer - ): string { + public static function projectLocationCollectionDataStoreSessionAnswerName(string $project, string $location, string $collection, string $dataStore, string $session, string $answer): string + { return self::getPathTemplate('projectLocationCollectionDataStoreSessionAnswer')->render([ 'project' => $project, 'location' => $location, @@ -372,13 +331,8 @@ public static function projectLocationCollectionDataStoreSessionAnswerName( * * @return string The formatted project_location_collection_engine_session resource. */ - public static function projectLocationCollectionEngineSessionName( - string $project, - string $location, - string $collection, - string $engine, - string $session - ): string { + public static function projectLocationCollectionEngineSessionName(string $project, string $location, string $collection, string $engine, string $session): string + { return self::getPathTemplate('projectLocationCollectionEngineSession')->render([ 'project' => $project, 'location' => $location, @@ -401,14 +355,8 @@ public static function projectLocationCollectionEngineSessionName( * * @return string The formatted project_location_collection_engine_session_answer resource. */ - public static function projectLocationCollectionEngineSessionAnswerName( - string $project, - string $location, - string $collection, - string $engine, - string $session, - string $answer - ): string { + public static function projectLocationCollectionEngineSessionAnswerName(string $project, string $location, string $collection, string $engine, string $session, string $answer): string + { return self::getPathTemplate('projectLocationCollectionEngineSessionAnswer')->render([ 'project' => $project, 'location' => $location, @@ -450,13 +398,8 @@ public static function projectLocationDataStoreName(string $project, string $loc * * @return string The formatted project_location_data_store_branch_document resource. */ - public static function projectLocationDataStoreBranchDocumentName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document - ): string { + public static function projectLocationDataStoreBranchDocumentName(string $project, string $location, string $dataStore, string $branch, string $document): string + { return self::getPathTemplate('projectLocationDataStoreBranchDocument')->render([ 'project' => $project, 'location' => $location, @@ -479,14 +422,8 @@ public static function projectLocationDataStoreBranchDocumentName( * * @return string The formatted project_location_data_store_branch_document_chunk resource. */ - public static function projectLocationDataStoreBranchDocumentChunkName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document, - string $chunk - ): string { + public static function projectLocationDataStoreBranchDocumentChunkName(string $project, string $location, string $dataStore, string $branch, string $document, string $chunk): string + { return self::getPathTemplate('projectLocationDataStoreBranchDocumentChunk')->render([ 'project' => $project, 'location' => $location, @@ -508,12 +445,8 @@ public static function projectLocationDataStoreBranchDocumentChunkName( * * @return string The formatted project_location_data_store_session resource. */ - public static function projectLocationDataStoreSessionName( - string $project, - string $location, - string $dataStore, - string $session - ): string { + public static function projectLocationDataStoreSessionName(string $project, string $location, string $dataStore, string $session): string + { return self::getPathTemplate('projectLocationDataStoreSession')->render([ 'project' => $project, 'location' => $location, @@ -534,13 +467,8 @@ public static function projectLocationDataStoreSessionName( * * @return string The formatted project_location_data_store_session_answer resource. */ - public static function projectLocationDataStoreSessionAnswerName( - string $project, - string $location, - string $dataStore, - string $session, - string $answer - ): string { + public static function projectLocationDataStoreSessionAnswerName(string $project, string $location, string $dataStore, string $session, string $answer): string + { return self::getPathTemplate('projectLocationDataStoreSessionAnswer')->render([ 'project' => $project, 'location' => $location, @@ -614,25 +542,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'discoveryengine.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DiscoveryEngine\V1\SessionServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new SessionServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -670,11 +601,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/DiscoveryEngine/src/V1/Client/SiteSearchEngineServiceClient.php b/DiscoveryEngine/src/V1/Client/SiteSearchEngineServiceClient.php index 78ff90dfd6c3..6d6a7d745b3d 100644 --- a/DiscoveryEngine/src/V1/Client/SiteSearchEngineServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/SiteSearchEngineServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -35,13 +36,17 @@ use Google\ApiCore\ValidationException; use Google\Auth\FetchAuthTokenInterface; use Google\Cloud\DiscoveryEngine\V1\BatchCreateTargetSitesRequest; +use Google\Cloud\DiscoveryEngine\V1\BatchCreateTargetSitesResponse; use Google\Cloud\DiscoveryEngine\V1\BatchVerifyTargetSitesRequest; +use Google\Cloud\DiscoveryEngine\V1\BatchVerifyTargetSitesResponse; use Google\Cloud\DiscoveryEngine\V1\CreateSitemapRequest; use Google\Cloud\DiscoveryEngine\V1\CreateTargetSiteRequest; use Google\Cloud\DiscoveryEngine\V1\DeleteSitemapRequest; use Google\Cloud\DiscoveryEngine\V1\DeleteTargetSiteRequest; use Google\Cloud\DiscoveryEngine\V1\DisableAdvancedSiteSearchRequest; +use Google\Cloud\DiscoveryEngine\V1\DisableAdvancedSiteSearchResponse; use Google\Cloud\DiscoveryEngine\V1\EnableAdvancedSiteSearchRequest; +use Google\Cloud\DiscoveryEngine\V1\EnableAdvancedSiteSearchResponse; use Google\Cloud\DiscoveryEngine\V1\FetchDomainVerificationStatusRequest; use Google\Cloud\DiscoveryEngine\V1\FetchSitemapsRequest; use Google\Cloud\DiscoveryEngine\V1\FetchSitemapsResponse; @@ -49,6 +54,7 @@ use Google\Cloud\DiscoveryEngine\V1\GetTargetSiteRequest; use Google\Cloud\DiscoveryEngine\V1\ListTargetSitesRequest; use Google\Cloud\DiscoveryEngine\V1\RecrawlUrisRequest; +use Google\Cloud\DiscoveryEngine\V1\RecrawlUrisResponse; use Google\Cloud\DiscoveryEngine\V1\SiteSearchEngine; use Google\Cloud\DiscoveryEngine\V1\Sitemap; use Google\Cloud\DiscoveryEngine\V1\TargetSite; @@ -110,7 +116,9 @@ final class SiteSearchEngineServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -127,8 +135,7 @@ private static function getClientDefaults() ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => - __DIR__ . '/../resources/site_search_engine_service_rest_client_config.php', + 'restClientConfigPath' => __DIR__ . '/../resources/site_search_engine_service_rest_client_config.php', ], ], ]; @@ -157,9 +164,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -195,12 +200,8 @@ private function createOperationsClient(array $options) * * @return string The formatted project_location_collection_data_store_siteSearchEngine resource. */ - public static function projectLocationCollectionDataStoreSiteSearchEngineName( - string $project, - string $location, - string $collection, - string $dataStore - ): string { + public static function projectLocationCollectionDataStoreSiteSearchEngineName(string $project, string $location, string $collection, string $dataStore): string + { return self::getPathTemplate('projectLocationCollectionDataStoreSiteSearchEngine')->render([ 'project' => $project, 'location' => $location, @@ -221,13 +222,8 @@ public static function projectLocationCollectionDataStoreSiteSearchEngineName( * * @return string The formatted project_location_collection_data_store_sitemap resource. */ - public static function projectLocationCollectionDataStoreSitemapName( - string $project, - string $location, - string $collection, - string $dataStore, - string $sitemap - ): string { + public static function projectLocationCollectionDataStoreSitemapName(string $project, string $location, string $collection, string $dataStore, string $sitemap): string + { return self::getPathTemplate('projectLocationCollectionDataStoreSitemap')->render([ 'project' => $project, 'location' => $location, @@ -249,13 +245,8 @@ public static function projectLocationCollectionDataStoreSitemapName( * * @return string The formatted project_location_collection_data_store_target_site resource. */ - public static function projectLocationCollectionDataStoreTargetSiteName( - string $project, - string $location, - string $collection, - string $dataStore, - string $targetSite - ): string { + public static function projectLocationCollectionDataStoreTargetSiteName(string $project, string $location, string $collection, string $dataStore, string $targetSite): string + { return self::getPathTemplate('projectLocationCollectionDataStoreTargetSite')->render([ 'project' => $project, 'location' => $location, @@ -275,11 +266,8 @@ public static function projectLocationCollectionDataStoreTargetSiteName( * * @return string The formatted project_location_data_store_siteSearchEngine resource. */ - public static function projectLocationDataStoreSiteSearchEngineName( - string $project, - string $location, - string $dataStore - ): string { + public static function projectLocationDataStoreSiteSearchEngineName(string $project, string $location, string $dataStore): string + { return self::getPathTemplate('projectLocationDataStoreSiteSearchEngine')->render([ 'project' => $project, 'location' => $location, @@ -298,12 +286,8 @@ public static function projectLocationDataStoreSiteSearchEngineName( * * @return string The formatted project_location_data_store_sitemap resource. */ - public static function projectLocationDataStoreSitemapName( - string $project, - string $location, - string $dataStore, - string $sitemap - ): string { + public static function projectLocationDataStoreSitemapName(string $project, string $location, string $dataStore, string $sitemap): string + { return self::getPathTemplate('projectLocationDataStoreSitemap')->render([ 'project' => $project, 'location' => $location, @@ -323,12 +307,8 @@ public static function projectLocationDataStoreSitemapName( * * @return string The formatted project_location_data_store_target_site resource. */ - public static function projectLocationDataStoreTargetSiteName( - string $project, - string $location, - string $dataStore, - string $targetSite - ): string { + public static function projectLocationDataStoreTargetSiteName(string $project, string $location, string $dataStore, string $targetSite): string + { return self::getPathTemplate('projectLocationDataStoreTargetSite')->render([ 'project' => $project, 'location' => $location, @@ -388,12 +368,8 @@ public static function sitemapName(string $project, string $location, string $da * * @return string The formatted target_site resource. */ - public static function targetSiteName( - string $project, - string $location, - string $dataStore, - string $targetSite - ): string { + public static function targetSiteName(string $project, string $location, string $dataStore, string $targetSite): string + { return self::getPathTemplate('targetSite')->render([ 'project' => $project, 'location' => $location, @@ -437,25 +413,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'discoveryengine.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DiscoveryEngine\V1\SiteSearchEngineServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new SiteSearchEngineServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -493,11 +472,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -534,14 +515,12 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function batchCreateTargetSites( - BatchCreateTargetSitesRequest $request, - array $callOptions = [] - ): OperationResponse { + public function batchCreateTargetSites(BatchCreateTargetSitesRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('BatchCreateTargetSites', $request, $callOptions)->wait(); } @@ -565,14 +544,12 @@ public function batchCreateTargetSites( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function batchVerifyTargetSites( - BatchVerifyTargetSitesRequest $request, - array $callOptions = [] - ): OperationResponse { + public function batchVerifyTargetSites(BatchVerifyTargetSitesRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('BatchVerifyTargetSites', $request, $callOptions)->wait(); } @@ -594,7 +571,7 @@ public function batchVerifyTargetSites( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -621,7 +598,7 @@ public function createSitemap(CreateSitemapRequest $request, array $callOptions * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -648,7 +625,7 @@ public function createTargetSite(CreateTargetSiteRequest $request, array $callOp * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -675,7 +652,7 @@ public function deleteSitemap(DeleteSitemapRequest $request, array $callOptions * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -702,14 +679,12 @@ public function deleteTargetSite(DeleteTargetSiteRequest $request, array $callOp * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function disableAdvancedSiteSearch( - DisableAdvancedSiteSearchRequest $request, - array $callOptions = [] - ): OperationResponse { + public function disableAdvancedSiteSearch(DisableAdvancedSiteSearchRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('DisableAdvancedSiteSearch', $request, $callOptions)->wait(); } @@ -731,14 +706,12 @@ public function disableAdvancedSiteSearch( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function enableAdvancedSiteSearch( - EnableAdvancedSiteSearchRequest $request, - array $callOptions = [] - ): OperationResponse { + public function enableAdvancedSiteSearch(EnableAdvancedSiteSearchRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('EnableAdvancedSiteSearch', $request, $callOptions)->wait(); } @@ -766,10 +739,8 @@ public function enableAdvancedSiteSearch( * * @throws ApiException Thrown if the API call fails. */ - public function fetchDomainVerificationStatus( - FetchDomainVerificationStatusRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function fetchDomainVerificationStatus(FetchDomainVerificationStatusRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('FetchDomainVerificationStatus', $request, $callOptions); } @@ -900,7 +871,7 @@ public function listTargetSites(ListTargetSitesRequest $request, array $callOpti * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -927,7 +898,7 @@ public function recrawlUris(RecrawlUrisRequest $request, array $callOptions = [] * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ diff --git a/DiscoveryEngine/src/V1/Client/UserEventServiceClient.php b/DiscoveryEngine/src/V1/Client/UserEventServiceClient.php index cc40d328b341..868973652f88 100644 --- a/DiscoveryEngine/src/V1/Client/UserEventServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/UserEventServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; @@ -36,7 +37,9 @@ use Google\Auth\FetchAuthTokenInterface; use Google\Cloud\DiscoveryEngine\V1\CollectUserEventRequest; use Google\Cloud\DiscoveryEngine\V1\ImportUserEventsRequest; +use Google\Cloud\DiscoveryEngine\V1\ImportUserEventsResponse; use Google\Cloud\DiscoveryEngine\V1\PurgeUserEventsRequest; +use Google\Cloud\DiscoveryEngine\V1\PurgeUserEventsResponse; use Google\Cloud\DiscoveryEngine\V1\UserEvent; use Google\Cloud\DiscoveryEngine\V1\WriteUserEventRequest; use Google\LongRunning\Client\OperationsClient; @@ -85,7 +88,9 @@ final class UserEventServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -131,9 +136,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -189,13 +192,8 @@ public static function dataStoreName(string $project, string $location, string $ * * @return string The formatted document resource. */ - public static function documentName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document - ): string { + public static function documentName(string $project, string $location, string $dataStore, string $branch, string $document): string + { return self::getPathTemplate('document')->render([ 'project' => $project, 'location' => $location, @@ -237,12 +235,8 @@ public static function engineName(string $project, string $location, string $col * * @return string The formatted project_location_collection_data_store resource. */ - public static function projectLocationCollectionDataStoreName( - string $project, - string $location, - string $collection, - string $dataStore - ): string { + public static function projectLocationCollectionDataStoreName(string $project, string $location, string $collection, string $dataStore): string + { return self::getPathTemplate('projectLocationCollectionDataStore')->render([ 'project' => $project, 'location' => $location, @@ -264,14 +258,8 @@ public static function projectLocationCollectionDataStoreName( * * @return string The formatted project_location_collection_data_store_branch_document resource. */ - public static function projectLocationCollectionDataStoreBranchDocumentName( - string $project, - string $location, - string $collection, - string $dataStore, - string $branch, - string $document - ): string { + public static function projectLocationCollectionDataStoreBranchDocumentName(string $project, string $location, string $collection, string $dataStore, string $branch, string $document): string + { return self::getPathTemplate('projectLocationCollectionDataStoreBranchDocument')->render([ 'project' => $project, 'location' => $location, @@ -313,13 +301,8 @@ public static function projectLocationDataStoreName(string $project, string $loc * * @return string The formatted project_location_data_store_branch_document resource. */ - public static function projectLocationDataStoreBranchDocumentName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document - ): string { + public static function projectLocationDataStoreBranchDocumentName(string $project, string $location, string $dataStore, string $branch, string $document): string + { return self::getPathTemplate('projectLocationDataStoreBranchDocument')->render([ 'project' => $project, 'location' => $location, @@ -362,25 +345,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'discoveryengine.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DiscoveryEngine\V1\UserEventServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new UserEventServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -418,11 +404,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -493,7 +481,7 @@ public function collectUserEvent(CollectUserEventRequest $request, array $callOp * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -522,7 +510,7 @@ public function importUserEvents(ImportUserEventsRequest $request, array $callOp * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ diff --git a/DiscoveryEngine/src/V1/Client/UserLicenseServiceClient.php b/DiscoveryEngine/src/V1/Client/UserLicenseServiceClient.php index 18f3a941ca09..49d53806a11f 100644 --- a/DiscoveryEngine/src/V1/Client/UserLicenseServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/UserLicenseServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -35,6 +36,7 @@ use Google\ApiCore\ValidationException; use Google\Auth\FetchAuthTokenInterface; use Google\Cloud\DiscoveryEngine\V1\BatchUpdateUserLicensesRequest; +use Google\Cloud\DiscoveryEngine\V1\BatchUpdateUserLicensesResponse; use Google\Cloud\DiscoveryEngine\V1\ListUserLicensesRequest; use Google\LongRunning\Client\OperationsClient; use Google\LongRunning\Operation; @@ -80,7 +82,9 @@ final class UserLicenseServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -126,9 +130,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -219,25 +221,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'discoveryengine.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DiscoveryEngine\V1\UserLicenseServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new UserLicenseServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -275,11 +280,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -316,14 +323,12 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function batchUpdateUserLicenses( - BatchUpdateUserLicensesRequest $request, - array $callOptions = [] - ): OperationResponse { + public function batchUpdateUserLicenses(BatchUpdateUserLicensesRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('BatchUpdateUserLicenses', $request, $callOptions)->wait(); } diff --git a/Dlp/src/V2/Client/DlpServiceClient.php b/Dlp/src/V2/Client/DlpServiceClient.php index 5216a632112c..390592ec4bb6 100644 --- a/Dlp/src/V2/Client/DlpServiceClient.php +++ b/Dlp/src/V2/Client/DlpServiceClient.php @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -204,7 +205,9 @@ final class DlpServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private static function getClientDefaults() { @@ -235,11 +238,8 @@ private static function getClientDefaults() * * @return string The formatted column_data_profile resource. */ - public static function columnDataProfileName( - string $organization, - string $location, - string $columnDataProfile - ): string { + public static function columnDataProfileName(string $organization, string $location, string $columnDataProfile): string + { return self::getPathTemplate('columnDataProfile')->render([ 'organization' => $organization, 'location' => $location, @@ -329,11 +329,8 @@ public static function dlpJobName(string $project, string $dlpJob): string * * @return string The formatted file_store_data_profile resource. */ - public static function fileStoreDataProfileName( - string $organization, - string $location, - string $fileStoreDataProfile - ): string { + public static function fileStoreDataProfileName(string $organization, string $location, string $fileStoreDataProfile): string + { return self::getPathTemplate('fileStoreDataProfile')->render([ 'organization' => $organization, 'location' => $location, @@ -468,11 +465,8 @@ public static function organizationLocationName(string $organization, string $lo * * @return string The formatted organization_location_column_data_profile resource. */ - public static function organizationLocationColumnDataProfileName( - string $organization, - string $location, - string $columnDataProfile - ): string { + public static function organizationLocationColumnDataProfileName(string $organization, string $location, string $columnDataProfile): string + { return self::getPathTemplate('organizationLocationColumnDataProfile')->render([ 'organization' => $organization, 'location' => $location, @@ -490,11 +484,8 @@ public static function organizationLocationColumnDataProfileName( * * @return string The formatted organization_location_connection resource. */ - public static function organizationLocationConnectionName( - string $organization, - string $location, - string $connection - ): string { + public static function organizationLocationConnectionName(string $organization, string $location, string $connection): string + { return self::getPathTemplate('organizationLocationConnection')->render([ 'organization' => $organization, 'location' => $location, @@ -512,11 +503,8 @@ public static function organizationLocationConnectionName( * * @return string The formatted organization_location_deidentify_template resource. */ - public static function organizationLocationDeidentifyTemplateName( - string $organization, - string $location, - string $deidentifyTemplate - ): string { + public static function organizationLocationDeidentifyTemplateName(string $organization, string $location, string $deidentifyTemplate): string + { return self::getPathTemplate('organizationLocationDeidentifyTemplate')->render([ 'organization' => $organization, 'location' => $location, @@ -534,11 +522,8 @@ public static function organizationLocationDeidentifyTemplateName( * * @return string The formatted organization_location_file_store_data_profile resource. */ - public static function organizationLocationFileStoreDataProfileName( - string $organization, - string $location, - string $fileStoreDataProfile - ): string { + public static function organizationLocationFileStoreDataProfileName(string $organization, string $location, string $fileStoreDataProfile): string + { return self::getPathTemplate('organizationLocationFileStoreDataProfile')->render([ 'organization' => $organization, 'location' => $location, @@ -556,11 +541,8 @@ public static function organizationLocationFileStoreDataProfileName( * * @return string The formatted organization_location_inspect_template resource. */ - public static function organizationLocationInspectTemplateName( - string $organization, - string $location, - string $inspectTemplate - ): string { + public static function organizationLocationInspectTemplateName(string $organization, string $location, string $inspectTemplate): string + { return self::getPathTemplate('organizationLocationInspectTemplate')->render([ 'organization' => $organization, 'location' => $location, @@ -578,11 +560,8 @@ public static function organizationLocationInspectTemplateName( * * @return string The formatted organization_location_project_data_profile resource. */ - public static function organizationLocationProjectDataProfileName( - string $organization, - string $location, - string $projectDataProfile - ): string { + public static function organizationLocationProjectDataProfileName(string $organization, string $location, string $projectDataProfile): string + { return self::getPathTemplate('organizationLocationProjectDataProfile')->render([ 'organization' => $organization, 'location' => $location, @@ -600,11 +579,8 @@ public static function organizationLocationProjectDataProfileName( * * @return string The formatted organization_location_stored_info_type resource. */ - public static function organizationLocationStoredInfoTypeName( - string $organization, - string $location, - string $storedInfoType - ): string { + public static function organizationLocationStoredInfoTypeName(string $organization, string $location, string $storedInfoType): string + { return self::getPathTemplate('organizationLocationStoredInfoType')->render([ 'organization' => $organization, 'location' => $location, @@ -622,11 +598,8 @@ public static function organizationLocationStoredInfoTypeName( * * @return string The formatted organization_location_table_data_profile resource. */ - public static function organizationLocationTableDataProfileName( - string $organization, - string $location, - string $tableDataProfile - ): string { + public static function organizationLocationTableDataProfileName(string $organization, string $location, string $tableDataProfile): string + { return self::getPathTemplate('organizationLocationTableDataProfile')->render([ 'organization' => $organization, 'location' => $location, @@ -676,11 +649,8 @@ public static function projectName(string $project): string * * @return string The formatted project_data_profile resource. */ - public static function projectDataProfileName( - string $organization, - string $location, - string $projectDataProfile - ): string { + public static function projectDataProfileName(string $organization, string $location, string $projectDataProfile): string + { return self::getPathTemplate('projectDataProfile')->render([ 'organization' => $organization, 'location' => $location, @@ -766,11 +736,8 @@ public static function projectJobTriggerName(string $project, string $jobTrigger * * @return string The formatted project_location_column_data_profile resource. */ - public static function projectLocationColumnDataProfileName( - string $project, - string $location, - string $columnDataProfile - ): string { + public static function projectLocationColumnDataProfileName(string $project, string $location, string $columnDataProfile): string + { return self::getPathTemplate('projectLocationColumnDataProfile')->render([ 'project' => $project, 'location' => $location, @@ -807,11 +774,8 @@ public static function projectLocationConnectionName(string $project, string $lo * * @return string The formatted project_location_deidentify_template resource. */ - public static function projectLocationDeidentifyTemplateName( - string $project, - string $location, - string $deidentifyTemplate - ): string { + public static function projectLocationDeidentifyTemplateName(string $project, string $location, string $deidentifyTemplate): string + { return self::getPathTemplate('projectLocationDeidentifyTemplate')->render([ 'project' => $project, 'location' => $location, @@ -848,11 +812,8 @@ public static function projectLocationDlpJobName(string $project, string $locati * * @return string The formatted project_location_file_store_data_profile resource. */ - public static function projectLocationFileStoreDataProfileName( - string $project, - string $location, - string $fileStoreDataProfile - ): string { + public static function projectLocationFileStoreDataProfileName(string $project, string $location, string $fileStoreDataProfile): string + { return self::getPathTemplate('projectLocationFileStoreDataProfile')->render([ 'project' => $project, 'location' => $location, @@ -870,11 +831,8 @@ public static function projectLocationFileStoreDataProfileName( * * @return string The formatted project_location_inspect_template resource. */ - public static function projectLocationInspectTemplateName( - string $project, - string $location, - string $inspectTemplate - ): string { + public static function projectLocationInspectTemplateName(string $project, string $location, string $inspectTemplate): string + { return self::getPathTemplate('projectLocationInspectTemplate')->render([ 'project' => $project, 'location' => $location, @@ -911,11 +869,8 @@ public static function projectLocationJobTriggerName(string $project, string $lo * * @return string The formatted project_location_project_data_profile resource. */ - public static function projectLocationProjectDataProfileName( - string $project, - string $location, - string $projectDataProfile - ): string { + public static function projectLocationProjectDataProfileName(string $project, string $location, string $projectDataProfile): string + { return self::getPathTemplate('projectLocationProjectDataProfile')->render([ 'project' => $project, 'location' => $location, @@ -933,11 +888,8 @@ public static function projectLocationProjectDataProfileName( * * @return string The formatted project_location_stored_info_type resource. */ - public static function projectLocationStoredInfoTypeName( - string $project, - string $location, - string $storedInfoType - ): string { + public static function projectLocationStoredInfoTypeName(string $project, string $location, string $storedInfoType): string + { return self::getPathTemplate('projectLocationStoredInfoType')->render([ 'project' => $project, 'location' => $location, @@ -955,11 +907,8 @@ public static function projectLocationStoredInfoTypeName( * * @return string The formatted project_location_table_data_profile resource. */ - public static function projectLocationTableDataProfileName( - string $project, - string $location, - string $tableDataProfile - ): string { + public static function projectLocationTableDataProfileName(string $project, string $location, string $tableDataProfile): string + { return self::getPathTemplate('projectLocationTableDataProfile')->render([ 'project' => $project, 'location' => $location, @@ -1011,11 +960,8 @@ public static function storedInfoTypeName(string $organization, string $storedIn * * @return string The formatted table_data_profile resource. */ - public static function tableDataProfileName( - string $organization, - string $location, - string $tableDataProfile - ): string { + public static function tableDataProfileName(string $organization, string $location, string $tableDataProfile): string + { return self::getPathTemplate('tableDataProfile')->render([ 'organization' => $organization, 'location' => $location, @@ -1090,25 +1036,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'dlp.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Dlp\V2\DlpServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new DlpServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -1146,11 +1095,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -1276,10 +1227,8 @@ public function createConnection(CreateConnectionRequest $request, array $callOp * * @throws ApiException Thrown if the API call fails. */ - public function createDeidentifyTemplate( - CreateDeidentifyTemplateRequest $request, - array $callOptions = [] - ): DeidentifyTemplate { + public function createDeidentifyTemplate(CreateDeidentifyTemplateRequest $request, array $callOptions = []): DeidentifyTemplate + { return $this->startApiCall('CreateDeidentifyTemplate', $request, $callOptions)->wait(); } @@ -1304,10 +1253,8 @@ public function createDeidentifyTemplate( * * @throws ApiException Thrown if the API call fails. */ - public function createDiscoveryConfig( - CreateDiscoveryConfigRequest $request, - array $callOptions = [] - ): DiscoveryConfig { + public function createDiscoveryConfig(CreateDiscoveryConfigRequest $request, array $callOptions = []): DiscoveryConfig + { return $this->startApiCall('CreateDiscoveryConfig', $request, $callOptions)->wait(); } @@ -1371,10 +1318,8 @@ public function createDlpJob(CreateDlpJobRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function createInspectTemplate( - CreateInspectTemplateRequest $request, - array $callOptions = [] - ): InspectTemplate { + public function createInspectTemplate(CreateInspectTemplateRequest $request, array $callOptions = []): InspectTemplate + { return $this->startApiCall('CreateInspectTemplate', $request, $callOptions)->wait(); } @@ -1466,10 +1411,8 @@ public function createStoredInfoType(CreateStoredInfoTypeRequest $request, array * * @throws ApiException Thrown if the API call fails. */ - public function deidentifyContent( - DeidentifyContentRequest $request, - array $callOptions = [] - ): DeidentifyContentResponse { + public function deidentifyContent(DeidentifyContentRequest $request, array $callOptions = []): DeidentifyContentResponse + { return $this->startApiCall('DeidentifyContent', $request, $callOptions)->wait(); } @@ -1600,10 +1543,8 @@ public function deleteDlpJob(DeleteDlpJobRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function deleteFileStoreDataProfile( - DeleteFileStoreDataProfileRequest $request, - array $callOptions = [] - ): void { + public function deleteFileStoreDataProfile(DeleteFileStoreDataProfileRequest $request, array $callOptions = []): void + { $this->startApiCall('DeleteFileStoreDataProfile', $request, $callOptions)->wait(); } @@ -1759,10 +1700,8 @@ public function finishDlpJob(FinishDlpJobRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function getColumnDataProfile( - GetColumnDataProfileRequest $request, - array $callOptions = [] - ): ColumnDataProfile { + public function getColumnDataProfile(GetColumnDataProfileRequest $request, array $callOptions = []): ColumnDataProfile + { return $this->startApiCall('GetColumnDataProfile', $request, $callOptions)->wait(); } @@ -1816,10 +1755,8 @@ public function getConnection(GetConnectionRequest $request, array $callOptions * * @throws ApiException Thrown if the API call fails. */ - public function getDeidentifyTemplate( - GetDeidentifyTemplateRequest $request, - array $callOptions = [] - ): DeidentifyTemplate { + public function getDeidentifyTemplate(GetDeidentifyTemplateRequest $request, array $callOptions = []): DeidentifyTemplate + { return $this->startApiCall('GetDeidentifyTemplate', $request, $callOptions)->wait(); } @@ -1901,10 +1838,8 @@ public function getDlpJob(GetDlpJobRequest $request, array $callOptions = []): D * * @throws ApiException Thrown if the API call fails. */ - public function getFileStoreDataProfile( - GetFileStoreDataProfileRequest $request, - array $callOptions = [] - ): FileStoreDataProfile { + public function getFileStoreDataProfile(GetFileStoreDataProfileRequest $request, array $callOptions = []): FileStoreDataProfile + { return $this->startApiCall('GetFileStoreDataProfile', $request, $callOptions)->wait(); } @@ -1987,10 +1922,8 @@ public function getJobTrigger(GetJobTriggerRequest $request, array $callOptions * * @throws ApiException Thrown if the API call fails. */ - public function getProjectDataProfile( - GetProjectDataProfileRequest $request, - array $callOptions = [] - ): ProjectDataProfile { + public function getProjectDataProfile(GetProjectDataProfileRequest $request, array $callOptions = []): ProjectDataProfile + { return $this->startApiCall('GetProjectDataProfile', $request, $callOptions)->wait(); } @@ -2072,10 +2005,8 @@ public function getTableDataProfile(GetTableDataProfileRequest $request, array $ * * @throws ApiException Thrown if the API call fails. */ - public function hybridInspectDlpJob( - HybridInspectDlpJobRequest $request, - array $callOptions = [] - ): HybridInspectResponse { + public function hybridInspectDlpJob(HybridInspectDlpJobRequest $request, array $callOptions = []): HybridInspectResponse + { return $this->startApiCall('HybridInspectDlpJob', $request, $callOptions)->wait(); } @@ -2102,10 +2033,8 @@ public function hybridInspectDlpJob( * * @throws ApiException Thrown if the API call fails. */ - public function hybridInspectJobTrigger( - HybridInspectJobTriggerRequest $request, - array $callOptions = [] - ): HybridInspectResponse { + public function hybridInspectJobTrigger(HybridInspectJobTriggerRequest $request, array $callOptions = []): HybridInspectResponse + { return $this->startApiCall('HybridInspectJobTrigger', $request, $callOptions)->wait(); } @@ -2166,10 +2095,8 @@ public function inspectContent(InspectContentRequest $request, array $callOption * * @throws ApiException Thrown if the API call fails. */ - public function listColumnDataProfiles( - ListColumnDataProfilesRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listColumnDataProfiles(ListColumnDataProfilesRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListColumnDataProfiles', $request, $callOptions); } @@ -2224,10 +2151,8 @@ public function listConnections(ListConnectionsRequest $request, array $callOpti * * @throws ApiException Thrown if the API call fails. */ - public function listDeidentifyTemplates( - ListDeidentifyTemplatesRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listDeidentifyTemplates(ListDeidentifyTemplatesRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListDeidentifyTemplates', $request, $callOptions); } @@ -2252,10 +2177,8 @@ public function listDeidentifyTemplates( * * @throws ApiException Thrown if the API call fails. */ - public function listDiscoveryConfigs( - ListDiscoveryConfigsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listDiscoveryConfigs(ListDiscoveryConfigsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListDiscoveryConfigs', $request, $callOptions); } @@ -2311,10 +2234,8 @@ public function listDlpJobs(ListDlpJobsRequest $request, array $callOptions = [] * * @throws ApiException Thrown if the API call fails. */ - public function listFileStoreDataProfiles( - ListFileStoreDataProfilesRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listFileStoreDataProfiles(ListFileStoreDataProfilesRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListFileStoreDataProfiles', $request, $callOptions); } @@ -2371,10 +2292,8 @@ public function listInfoTypes(ListInfoTypesRequest $request, array $callOptions * * @throws ApiException Thrown if the API call fails. */ - public function listInspectTemplates( - ListInspectTemplatesRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listInspectTemplates(ListInspectTemplatesRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListInspectTemplates', $request, $callOptions); } @@ -2428,10 +2347,8 @@ public function listJobTriggers(ListJobTriggersRequest $request, array $callOpti * * @throws ApiException Thrown if the API call fails. */ - public function listProjectDataProfiles( - ListProjectDataProfilesRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listProjectDataProfiles(ListProjectDataProfilesRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListProjectDataProfiles', $request, $callOptions); } @@ -2485,10 +2402,8 @@ public function listStoredInfoTypes(ListStoredInfoTypesRequest $request, array $ * * @throws ApiException Thrown if the API call fails. */ - public function listTableDataProfiles( - ListTableDataProfilesRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listTableDataProfiles(ListTableDataProfilesRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListTableDataProfiles', $request, $callOptions); } @@ -2553,10 +2468,8 @@ public function redactImage(RedactImageRequest $request, array $callOptions = [] * * @throws ApiException Thrown if the API call fails. */ - public function reidentifyContent( - ReidentifyContentRequest $request, - array $callOptions = [] - ): ReidentifyContentResponse { + public function reidentifyContent(ReidentifyContentRequest $request, array $callOptions = []): ReidentifyContentResponse + { return $this->startApiCall('ReidentifyContent', $request, $callOptions)->wait(); } @@ -2636,10 +2549,8 @@ public function updateConnection(UpdateConnectionRequest $request, array $callOp * * @throws ApiException Thrown if the API call fails. */ - public function updateDeidentifyTemplate( - UpdateDeidentifyTemplateRequest $request, - array $callOptions = [] - ): DeidentifyTemplate { + public function updateDeidentifyTemplate(UpdateDeidentifyTemplateRequest $request, array $callOptions = []): DeidentifyTemplate + { return $this->startApiCall('UpdateDeidentifyTemplate', $request, $callOptions)->wait(); } @@ -2664,10 +2575,8 @@ public function updateDeidentifyTemplate( * * @throws ApiException Thrown if the API call fails. */ - public function updateDiscoveryConfig( - UpdateDiscoveryConfigRequest $request, - array $callOptions = [] - ): DiscoveryConfig { + public function updateDiscoveryConfig(UpdateDiscoveryConfigRequest $request, array $callOptions = []): DiscoveryConfig + { return $this->startApiCall('UpdateDiscoveryConfig', $request, $callOptions)->wait(); } @@ -2695,10 +2604,8 @@ public function updateDiscoveryConfig( * * @throws ApiException Thrown if the API call fails. */ - public function updateInspectTemplate( - UpdateInspectTemplateRequest $request, - array $callOptions = [] - ): InspectTemplate { + public function updateInspectTemplate(UpdateInspectTemplateRequest $request, array $callOptions = []): InspectTemplate + { return $this->startApiCall('UpdateInspectTemplate', $request, $callOptions)->wait(); } diff --git a/Dms/src/V1/Client/DataMigrationServiceClient.php b/Dms/src/V1/Client/DataMigrationServiceClient.php index e32b0364ac0e..7af17cf46c70 100644 --- a/Dms/src/V1/Client/DataMigrationServiceClient.php +++ b/Dms/src/V1/Client/DataMigrationServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -167,7 +168,9 @@ final class DataMigrationServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -213,9 +216,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -269,11 +270,8 @@ public static function connectionProfileName(string $project, string $location, * * @return string The formatted conversion_workspace resource. */ - public static function conversionWorkspaceName( - string $project, - string $location, - string $conversionWorkspace - ): string { + public static function conversionWorkspaceName(string $project, string $location, string $conversionWorkspace): string + { return self::getPathTemplate('conversionWorkspace')->render([ 'project' => $project, 'location' => $location, @@ -309,12 +307,8 @@ public static function locationName(string $project, string $location): string * * @return string The formatted mapping_rule resource. */ - public static function mappingRuleName( - string $project, - string $location, - string $conversionWorkspace, - string $mappingRule - ): string { + public static function mappingRuleName(string $project, string $location, string $conversionWorkspace, string $mappingRule): string + { return self::getPathTemplate('mappingRule')->render([ 'project' => $project, 'location' => $location, @@ -411,25 +405,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'datamigration.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\CloudDms\V1\DataMigrationServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new DataMigrationServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -467,11 +464,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -507,14 +506,12 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function applyConversionWorkspace( - ApplyConversionWorkspaceRequest $request, - array $callOptions = [] - ): OperationResponse { + public function applyConversionWorkspace(ApplyConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('ApplyConversionWorkspace', $request, $callOptions)->wait(); } @@ -536,14 +533,12 @@ public function applyConversionWorkspace( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function commitConversionWorkspace( - CommitConversionWorkspaceRequest $request, - array $callOptions = [] - ): OperationResponse { + public function commitConversionWorkspace(CommitConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('CommitConversionWorkspace', $request, $callOptions)->wait(); } @@ -565,14 +560,12 @@ public function commitConversionWorkspace( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function convertConversionWorkspace( - ConvertConversionWorkspaceRequest $request, - array $callOptions = [] - ): OperationResponse { + public function convertConversionWorkspace(ConvertConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('ConvertConversionWorkspace', $request, $callOptions)->wait(); } @@ -594,14 +587,12 @@ public function convertConversionWorkspace( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function createConnectionProfile( - CreateConnectionProfileRequest $request, - array $callOptions = [] - ): OperationResponse { + public function createConnectionProfile(CreateConnectionProfileRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('CreateConnectionProfile', $request, $callOptions)->wait(); } @@ -623,14 +614,12 @@ public function createConnectionProfile( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function createConversionWorkspace( - CreateConversionWorkspaceRequest $request, - array $callOptions = [] - ): OperationResponse { + public function createConversionWorkspace(CreateConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('CreateConversionWorkspace', $request, $callOptions)->wait(); } @@ -679,7 +668,7 @@ public function createMappingRule(CreateMappingRuleRequest $request, array $call * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -706,14 +695,12 @@ public function createMigrationJob(CreateMigrationJobRequest $request, array $ca * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function createPrivateConnection( - CreatePrivateConnectionRequest $request, - array $callOptions = [] - ): OperationResponse { + public function createPrivateConnection(CreatePrivateConnectionRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('CreatePrivateConnection', $request, $callOptions)->wait(); } @@ -737,14 +724,12 @@ public function createPrivateConnection( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function deleteConnectionProfile( - DeleteConnectionProfileRequest $request, - array $callOptions = [] - ): OperationResponse { + public function deleteConnectionProfile(DeleteConnectionProfileRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('DeleteConnectionProfile', $request, $callOptions)->wait(); } @@ -766,14 +751,12 @@ public function deleteConnectionProfile( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function deleteConversionWorkspace( - DeleteConversionWorkspaceRequest $request, - array $callOptions = [] - ): OperationResponse { + public function deleteConversionWorkspace(DeleteConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('DeleteConversionWorkspace', $request, $callOptions)->wait(); } @@ -820,7 +803,7 @@ public function deleteMappingRule(DeleteMappingRuleRequest $request, array $call * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -847,14 +830,12 @@ public function deleteMigrationJob(DeleteMigrationJobRequest $request, array $ca * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function deletePrivateConnection( - DeletePrivateConnectionRequest $request, - array $callOptions = [] - ): OperationResponse { + public function deletePrivateConnection(DeletePrivateConnectionRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('DeletePrivateConnection', $request, $callOptions)->wait(); } @@ -881,10 +862,8 @@ public function deletePrivateConnection( * * @throws ApiException Thrown if the API call fails. */ - public function describeConversionWorkspaceRevisions( - DescribeConversionWorkspaceRevisionsRequest $request, - array $callOptions = [] - ): DescribeConversionWorkspaceRevisionsResponse { + public function describeConversionWorkspaceRevisions(DescribeConversionWorkspaceRevisionsRequest $request, array $callOptions = []): DescribeConversionWorkspaceRevisionsResponse + { return $this->startApiCall('DescribeConversionWorkspaceRevisions', $request, $callOptions)->wait(); } @@ -915,10 +894,8 @@ public function describeConversionWorkspaceRevisions( * * @throws ApiException Thrown if the API call fails. */ - public function describeDatabaseEntities( - DescribeDatabaseEntitiesRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function describeDatabaseEntities(DescribeDatabaseEntitiesRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('DescribeDatabaseEntities', $request, $callOptions); } @@ -1000,10 +977,8 @@ public function generateSshScript(GenerateSshScriptRequest $request, array $call * * @throws ApiException Thrown if the API call fails. */ - public function generateTcpProxyScript( - GenerateTcpProxyScriptRequest $request, - array $callOptions = [] - ): TcpProxyScript { + public function generateTcpProxyScript(GenerateTcpProxyScriptRequest $request, array $callOptions = []): TcpProxyScript + { return $this->startApiCall('GenerateTcpProxyScript', $request, $callOptions)->wait(); } @@ -1029,10 +1004,8 @@ public function generateTcpProxyScript( * * @throws ApiException Thrown if the API call fails. */ - public function getConnectionProfile( - GetConnectionProfileRequest $request, - array $callOptions = [] - ): ConnectionProfile { + public function getConnectionProfile(GetConnectionProfileRequest $request, array $callOptions = []): ConnectionProfile + { return $this->startApiCall('GetConnectionProfile', $request, $callOptions)->wait(); } @@ -1058,10 +1031,8 @@ public function getConnectionProfile( * * @throws ApiException Thrown if the API call fails. */ - public function getConversionWorkspace( - GetConversionWorkspaceRequest $request, - array $callOptions = [] - ): ConversionWorkspace { + public function getConversionWorkspace(GetConversionWorkspaceRequest $request, array $callOptions = []): ConversionWorkspace + { return $this->startApiCall('GetConversionWorkspace', $request, $callOptions)->wait(); } @@ -1139,10 +1110,8 @@ public function getMigrationJob(GetMigrationJobRequest $request, array $callOpti * * @throws ApiException Thrown if the API call fails. */ - public function getPrivateConnection( - GetPrivateConnectionRequest $request, - array $callOptions = [] - ): PrivateConnection { + public function getPrivateConnection(GetPrivateConnectionRequest $request, array $callOptions = []): PrivateConnection + { return $this->startApiCall('GetPrivateConnection', $request, $callOptions)->wait(); } @@ -1165,7 +1134,7 @@ public function getPrivateConnection( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1197,10 +1166,8 @@ public function importMappingRules(ImportMappingRulesRequest $request, array $ca * * @throws ApiException Thrown if the API call fails. */ - public function listConnectionProfiles( - ListConnectionProfilesRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listConnectionProfiles(ListConnectionProfilesRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListConnectionProfiles', $request, $callOptions); } @@ -1226,10 +1193,8 @@ public function listConnectionProfiles( * * @throws ApiException Thrown if the API call fails. */ - public function listConversionWorkspaces( - ListConversionWorkspacesRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listConversionWorkspaces(ListConversionWorkspacesRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListConversionWorkspaces', $request, $callOptions); } @@ -1309,10 +1274,8 @@ public function listMigrationJobs(ListMigrationJobsRequest $request, array $call * * @throws ApiException Thrown if the API call fails. */ - public function listPrivateConnections( - ListPrivateConnectionsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listPrivateConnections(ListPrivateConnectionsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListPrivateConnections', $request, $callOptions); } @@ -1335,7 +1298,7 @@ public function listPrivateConnections( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1364,7 +1327,7 @@ public function promoteMigrationJob(PromoteMigrationJobRequest $request, array $ * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1392,7 +1355,7 @@ public function restartMigrationJob(RestartMigrationJobRequest $request, array $ * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1419,14 +1382,12 @@ public function resumeMigrationJob(ResumeMigrationJobRequest $request, array $ca * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function rollbackConversionWorkspace( - RollbackConversionWorkspaceRequest $request, - array $callOptions = [] - ): OperationResponse { + public function rollbackConversionWorkspace(RollbackConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('RollbackConversionWorkspace', $request, $callOptions)->wait(); } @@ -1457,10 +1418,8 @@ public function rollbackConversionWorkspace( * * @throws ApiException Thrown if the API call fails. */ - public function searchBackgroundJobs( - SearchBackgroundJobsRequest $request, - array $callOptions = [] - ): SearchBackgroundJobsResponse { + public function searchBackgroundJobs(SearchBackgroundJobsRequest $request, array $callOptions = []): SearchBackgroundJobsResponse + { return $this->startApiCall('SearchBackgroundJobs', $request, $callOptions)->wait(); } @@ -1483,14 +1442,12 @@ public function searchBackgroundJobs( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function seedConversionWorkspace( - SeedConversionWorkspaceRequest $request, - array $callOptions = [] - ): OperationResponse { + public function seedConversionWorkspace(SeedConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('SeedConversionWorkspace', $request, $callOptions)->wait(); } @@ -1512,7 +1469,7 @@ public function seedConversionWorkspace( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1539,7 +1496,7 @@ public function startMigrationJob(StartMigrationJobRequest $request, array $call * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1566,14 +1523,12 @@ public function stopMigrationJob(StopMigrationJobRequest $request, array $callOp * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function updateConnectionProfile( - UpdateConnectionProfileRequest $request, - array $callOptions = [] - ): OperationResponse { + public function updateConnectionProfile(UpdateConnectionProfileRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('UpdateConnectionProfile', $request, $callOptions)->wait(); } @@ -1595,14 +1550,12 @@ public function updateConnectionProfile( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function updateConversionWorkspace( - UpdateConversionWorkspaceRequest $request, - array $callOptions = [] - ): OperationResponse { + public function updateConversionWorkspace(UpdateConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('UpdateConversionWorkspace', $request, $callOptions)->wait(); } @@ -1624,7 +1577,7 @@ public function updateConversionWorkspace( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1652,7 +1605,7 @@ public function updateMigrationJob(UpdateMigrationJobRequest $request, array $ca * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ diff --git a/DocumentAi/src/V1/Client/DocumentProcessorServiceClient.php b/DocumentAi/src/V1/Client/DocumentProcessorServiceClient.php index a12224fad740..c3f4cb44f36f 100644 --- a/DocumentAi/src/V1/Client/DocumentProcessorServiceClient.php +++ b/DocumentAi/src/V1/Client/DocumentProcessorServiceClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -35,13 +36,18 @@ use Google\ApiCore\ValidationException; use Google\Auth\FetchAuthTokenInterface; use Google\Cloud\DocumentAI\V1\BatchProcessRequest; +use Google\Cloud\DocumentAI\V1\BatchProcessResponse; use Google\Cloud\DocumentAI\V1\CreateProcessorRequest; use Google\Cloud\DocumentAI\V1\DeleteProcessorRequest; use Google\Cloud\DocumentAI\V1\DeleteProcessorVersionRequest; use Google\Cloud\DocumentAI\V1\DeployProcessorVersionRequest; +use Google\Cloud\DocumentAI\V1\DeployProcessorVersionResponse; use Google\Cloud\DocumentAI\V1\DisableProcessorRequest; +use Google\Cloud\DocumentAI\V1\DisableProcessorResponse; use Google\Cloud\DocumentAI\V1\EnableProcessorRequest; +use Google\Cloud\DocumentAI\V1\EnableProcessorResponse; use Google\Cloud\DocumentAI\V1\EvaluateProcessorVersionRequest; +use Google\Cloud\DocumentAI\V1\EvaluateProcessorVersionResponse; use Google\Cloud\DocumentAI\V1\Evaluation; use Google\Cloud\DocumentAI\V1\FetchProcessorTypesRequest; use Google\Cloud\DocumentAI\V1\FetchProcessorTypesResponse; @@ -59,10 +65,14 @@ use Google\Cloud\DocumentAI\V1\ProcessorType; use Google\Cloud\DocumentAI\V1\ProcessorVersion; use Google\Cloud\DocumentAI\V1\ReviewDocumentRequest; +use Google\Cloud\DocumentAI\V1\ReviewDocumentResponse; use Google\Cloud\DocumentAI\V1\SetDefaultProcessorVersionRequest; +use Google\Cloud\DocumentAI\V1\SetDefaultProcessorVersionResponse; use Google\Cloud\DocumentAI\V1\TrainProcessorVersionMetadata; use Google\Cloud\DocumentAI\V1\TrainProcessorVersionRequest; +use Google\Cloud\DocumentAI\V1\TrainProcessorVersionResponse; use Google\Cloud\DocumentAI\V1\UndeployProcessorVersionRequest; +use Google\Cloud\DocumentAI\V1\UndeployProcessorVersionResponse; use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; @@ -135,7 +145,9 @@ final class DocumentProcessorServiceClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -152,8 +164,7 @@ private static function getClientDefaults() ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => - __DIR__ . '/../resources/document_processor_service_rest_client_config.php', + 'restClientConfigPath' => __DIR__ . '/../resources/document_processor_service_rest_client_config.php', ], ], ]; @@ -182,9 +193,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -221,13 +230,8 @@ private function createOperationsClient(array $options) * * @return string The formatted evaluation resource. */ - public static function evaluationName( - string $project, - string $location, - string $processor, - string $processorVersion, - string $evaluation - ): string { + public static function evaluationName(string $project, string $location, string $processor, string $processorVersion, string $evaluation): string + { return self::getPathTemplate('evaluation')->render([ 'project' => $project, 'location' => $location, @@ -322,12 +326,8 @@ public static function processorTypeName(string $project, string $location, stri * * @return string The formatted processor_version resource. */ - public static function processorVersionName( - string $project, - string $location, - string $processor, - string $processorVersion - ): string { + public static function processorVersionName(string $project, string $location, string $processor, string $processorVersion): string + { return self::getPathTemplate('processorVersion')->render([ 'project' => $project, 'location' => $location, @@ -368,25 +368,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'documentai.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\DocumentAI\V1\DocumentProcessorServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new DocumentProcessorServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -424,11 +427,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -465,7 +470,7 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -526,7 +531,7 @@ public function createProcessor(CreateProcessorRequest $request, array $callOpti * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -554,14 +559,12 @@ public function deleteProcessor(DeleteProcessorRequest $request, array $callOpti * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function deleteProcessorVersion( - DeleteProcessorVersionRequest $request, - array $callOptions = [] - ): OperationResponse { + public function deleteProcessorVersion(DeleteProcessorVersionRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('DeleteProcessorVersion', $request, $callOptions)->wait(); } @@ -583,14 +586,12 @@ public function deleteProcessorVersion( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function deployProcessorVersion( - DeployProcessorVersionRequest $request, - array $callOptions = [] - ): OperationResponse { + public function deployProcessorVersion(DeployProcessorVersionRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('DeployProcessorVersion', $request, $callOptions)->wait(); } @@ -612,7 +613,7 @@ public function deployProcessorVersion( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -639,7 +640,7 @@ public function disableProcessor(DisableProcessorRequest $request, array $callOp * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -667,14 +668,12 @@ public function enableProcessor(EnableProcessorRequest $request, array $callOpti * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function evaluateProcessorVersion( - EvaluateProcessorVersionRequest $request, - array $callOptions = [] - ): OperationResponse { + public function evaluateProcessorVersion(EvaluateProcessorVersionRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('EvaluateProcessorVersion', $request, $callOptions)->wait(); } @@ -702,10 +701,8 @@ public function evaluateProcessorVersion( * * @throws ApiException Thrown if the API call fails. */ - public function fetchProcessorTypes( - FetchProcessorTypesRequest $request, - array $callOptions = [] - ): FetchProcessorTypesResponse { + public function fetchProcessorTypes(FetchProcessorTypesRequest $request, array $callOptions = []): FetchProcessorTypesResponse + { return $this->startApiCall('FetchProcessorTypes', $request, $callOptions)->wait(); } @@ -893,10 +890,8 @@ public function listProcessorTypes(ListProcessorTypesRequest $request, array $ca * * @throws ApiException Thrown if the API call fails. */ - public function listProcessorVersions( - ListProcessorVersionsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listProcessorVersions(ListProcessorVersionsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListProcessorVersions', $request, $callOptions); } @@ -973,7 +968,7 @@ public function processDocument(ProcessRequest $request, array $callOptions = [] * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1004,14 +999,12 @@ public function reviewDocument(ReviewDocumentRequest $request, array $callOption * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function setDefaultProcessorVersion( - SetDefaultProcessorVersionRequest $request, - array $callOptions = [] - ): OperationResponse { + public function setDefaultProcessorVersion(SetDefaultProcessorVersionRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('SetDefaultProcessorVersion', $request, $callOptions)->wait(); } @@ -1035,14 +1028,12 @@ public function setDefaultProcessorVersion( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function trainProcessorVersion( - TrainProcessorVersionRequest $request, - array $callOptions = [] - ): OperationResponse { + public function trainProcessorVersion(TrainProcessorVersionRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('TrainProcessorVersion', $request, $callOptions)->wait(); } @@ -1064,14 +1055,12 @@ public function trainProcessorVersion( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function undeployProcessorVersion( - UndeployProcessorVersionRequest $request, - array $callOptions = [] - ): OperationResponse { + public function undeployProcessorVersion(UndeployProcessorVersionRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('UndeployProcessorVersion', $request, $callOptions)->wait(); } diff --git a/Domains/src/V1/Client/DomainsClient.php b/Domains/src/V1/Client/DomainsClient.php index 906b74b5879d..2fe12e3fbf46 100644 --- a/Domains/src/V1/Client/DomainsClient.php +++ b/Domains/src/V1/Client/DomainsClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -111,7 +112,9 @@ final class DomainsClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -157,9 +160,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -248,25 +249,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'domains.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\Domains\V1\DomainsClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new DomainsClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -304,11 +308,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -344,14 +350,12 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function configureContactSettings( - ConfigureContactSettingsRequest $request, - array $callOptions = [] - ): OperationResponse { + public function configureContactSettings(ConfigureContactSettingsRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('ConfigureContactSettings', $request, $callOptions)->wait(); } @@ -372,14 +376,12 @@ public function configureContactSettings( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function configureDnsSettings( - ConfigureDnsSettingsRequest $request, - array $callOptions = [] - ): OperationResponse { + public function configureDnsSettings(ConfigureDnsSettingsRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('ConfigureDnsSettings', $request, $callOptions)->wait(); } @@ -400,14 +402,12 @@ public function configureDnsSettings( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function configureManagementSettings( - ConfigureManagementSettingsRequest $request, - array $callOptions = [] - ): OperationResponse { + public function configureManagementSettings(ConfigureManagementSettingsRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('ConfigureManagementSettings', $request, $callOptions)->wait(); } @@ -446,7 +446,7 @@ public function configureManagementSettings( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -480,7 +480,7 @@ public function deleteRegistration(DeleteRegistrationRequest $request, array $ca * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -570,7 +570,7 @@ public function listRegistrations(ListRegistrationsRequest $request, array $call * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -603,10 +603,8 @@ public function registerDomain(RegisterDomainRequest $request, array $callOption * * @throws ApiException Thrown if the API call fails. */ - public function resetAuthorizationCode( - ResetAuthorizationCodeRequest $request, - array $callOptions = [] - ): AuthorizationCode { + public function resetAuthorizationCode(ResetAuthorizationCodeRequest $request, array $callOptions = []): AuthorizationCode + { return $this->startApiCall('ResetAuthorizationCode', $request, $callOptions)->wait(); } @@ -635,10 +633,8 @@ public function resetAuthorizationCode( * * @throws ApiException Thrown if the API call fails. */ - public function retrieveAuthorizationCode( - RetrieveAuthorizationCodeRequest $request, - array $callOptions = [] - ): AuthorizationCode { + public function retrieveAuthorizationCode(RetrieveAuthorizationCodeRequest $request, array $callOptions = []): AuthorizationCode + { return $this->startApiCall('RetrieveAuthorizationCode', $request, $callOptions)->wait(); } @@ -664,10 +660,8 @@ public function retrieveAuthorizationCode( * * @throws ApiException Thrown if the API call fails. */ - public function retrieveRegisterParameters( - RetrieveRegisterParametersRequest $request, - array $callOptions = [] - ): RetrieveRegisterParametersResponse { + public function retrieveRegisterParameters(RetrieveRegisterParametersRequest $request, array $callOptions = []): RetrieveRegisterParametersResponse + { return $this->startApiCall('RetrieveRegisterParameters', $request, $callOptions)->wait(); } @@ -697,10 +691,8 @@ public function retrieveRegisterParameters( * * @throws ApiException Thrown if the API call fails. */ - public function retrieveTransferParameters( - RetrieveTransferParametersRequest $request, - array $callOptions = [] - ): RetrieveTransferParametersResponse { + public function retrieveTransferParameters(RetrieveTransferParametersRequest $request, array $callOptions = []): RetrieveTransferParametersResponse + { return $this->startApiCall('RetrieveTransferParameters', $request, $callOptions)->wait(); } @@ -771,7 +763,7 @@ public function searchDomains(SearchDomainsRequest $request, array $callOptions * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -802,7 +794,7 @@ public function transferDomain(TransferDomainRequest $request, array $callOption * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ diff --git a/EdgeNetwork/src/V1/Client/EdgeNetworkClient.php b/EdgeNetwork/src/V1/Client/EdgeNetworkClient.php index 5809687ffb7b..aad5fe1358df 100644 --- a/EdgeNetwork/src/V1/Client/EdgeNetworkClient.php +++ b/EdgeNetwork/src/V1/Client/EdgeNetworkClient.php @@ -28,6 +28,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -146,7 +147,9 @@ final class EdgeNetworkClient private const CODEGEN_NAME = 'gapic'; /** The default scopes required by the service. */ - public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; private $operationsClient; @@ -192,9 +195,7 @@ public function getOperationsClient() */ public function resumeOperation($operationName, $methodName = null) { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; + $options = $this->descriptors[$methodName]['longRunning'] ?? []; $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); $operation->reload(); return $operation; @@ -230,12 +231,8 @@ private function createOperationsClient(array $options) * * @return string The formatted interconnect resource. */ - public static function interconnectName( - string $project, - string $location, - string $zone, - string $interconnect - ): string { + public static function interconnectName(string $project, string $location, string $zone, string $interconnect): string + { return self::getPathTemplate('interconnect')->render([ 'project' => $project, 'location' => $location, @@ -255,12 +252,8 @@ public static function interconnectName( * * @return string The formatted interconnect_attachment resource. */ - public static function interconnectAttachmentName( - string $project, - string $location, - string $zone, - string $interconnectAttachment - ): string { + public static function interconnectAttachmentName(string $project, string $location, string $zone, string $interconnectAttachment): string + { return self::getPathTemplate('interconnectAttachment')->render([ 'project' => $project, 'location' => $location, @@ -401,25 +394,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'edgenetwork.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\EdgeNetwork\V1\EdgeNetworkClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new EdgeNetworkClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -457,11 +453,13 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -497,14 +495,12 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function createInterconnectAttachment( - CreateInterconnectAttachmentRequest $request, - array $callOptions = [] - ): OperationResponse { + public function createInterconnectAttachment(CreateInterconnectAttachmentRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('CreateInterconnectAttachment', $request, $callOptions)->wait(); } @@ -525,7 +521,7 @@ public function createInterconnectAttachment( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -551,7 +547,7 @@ public function createNetwork(CreateNetworkRequest $request, array $callOptions * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -577,7 +573,7 @@ public function createRouter(CreateRouterRequest $request, array $callOptions = * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -604,14 +600,12 @@ public function createSubnet(CreateSubnetRequest $request, array $callOptions = * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ - public function deleteInterconnectAttachment( - DeleteInterconnectAttachmentRequest $request, - array $callOptions = [] - ): OperationResponse { + public function deleteInterconnectAttachment(DeleteInterconnectAttachmentRequest $request, array $callOptions = []): OperationResponse + { return $this->startApiCall('DeleteInterconnectAttachment', $request, $callOptions)->wait(); } @@ -632,7 +626,7 @@ public function deleteInterconnectAttachment( * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -658,7 +652,7 @@ public function deleteNetwork(DeleteNetworkRequest $request, array $callOptions * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -684,7 +678,7 @@ public function deleteRouter(DeleteRouterRequest $request, array $callOptions = * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -714,10 +708,8 @@ public function deleteSubnet(DeleteSubnetRequest $request, array $callOptions = * * @throws ApiException Thrown if the API call fails. */ - public function diagnoseInterconnect( - DiagnoseInterconnectRequest $request, - array $callOptions = [] - ): DiagnoseInterconnectResponse { + public function diagnoseInterconnect(DiagnoseInterconnectRequest $request, array $callOptions = []): DiagnoseInterconnectResponse + { return $this->startApiCall('DiagnoseInterconnect', $request, $callOptions)->wait(); } @@ -821,10 +813,8 @@ public function getInterconnect(GetInterconnectRequest $request, array $callOpti * * @throws ApiException Thrown if the API call fails. */ - public function getInterconnectAttachment( - GetInterconnectAttachmentRequest $request, - array $callOptions = [] - ): InterconnectAttachment { + public function getInterconnectAttachment(GetInterconnectAttachmentRequest $request, array $callOptions = []): InterconnectAttachment + { return $this->startApiCall('GetInterconnectAttachment', $request, $callOptions)->wait(); } @@ -983,10 +973,8 @@ public function initializeZone(InitializeZoneRequest $request, array $callOption * * @throws ApiException Thrown if the API call fails. */ - public function listInterconnectAttachments( - ListInterconnectAttachmentsRequest $request, - array $callOptions = [] - ): PagedListResponse { + public function listInterconnectAttachments(ListInterconnectAttachmentsRequest $request, array $callOptions = []): PagedListResponse + { return $this->startApiCall('ListInterconnectAttachments', $request, $callOptions); } @@ -1140,7 +1128,7 @@ public function listZones(ListZonesRequest $request, array $callOptions = []): P * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ @@ -1166,7 +1154,7 @@ public function updateRouter(UpdateRouterRequest $request, array $callOptions = * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. */ diff --git a/ErrorReporting/src/V1beta1/Client/ErrorGroupServiceClient.php b/ErrorReporting/src/V1beta1/Client/ErrorGroupServiceClient.php index b06a3a5e97f3..10c25fd278c8 100644 --- a/ErrorReporting/src/V1beta1/Client/ErrorGroupServiceClient.php +++ b/ErrorReporting/src/V1beta1/Client/ErrorGroupServiceClient.php @@ -29,6 +29,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; @@ -152,25 +153,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'clouderrorreporting.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\ErrorReporting\V1beta1\ErrorGroupServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new ErrorGroupServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -208,13 +212,15 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException * * @experimental */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/ErrorReporting/src/V1beta1/Client/ErrorStatsServiceClient.php b/ErrorReporting/src/V1beta1/Client/ErrorStatsServiceClient.php index e2abdac14106..d170772c89ed 100644 --- a/ErrorReporting/src/V1beta1/Client/ErrorStatsServiceClient.php +++ b/ErrorReporting/src/V1beta1/Client/ErrorStatsServiceClient.php @@ -29,6 +29,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\PagedListResponse; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; @@ -154,25 +155,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'clouderrorreporting.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\ErrorReporting\V1beta1\ErrorStatsServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new ErrorStatsServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -210,13 +214,15 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException * * @experimental */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); diff --git a/ErrorReporting/src/V1beta1/Client/ReportErrorsServiceClient.php b/ErrorReporting/src/V1beta1/Client/ReportErrorsServiceClient.php index a4dda41b3453..3478c4fc0206 100644 --- a/ErrorReporting/src/V1beta1/Client/ReportErrorsServiceClient.php +++ b/ErrorReporting/src/V1beta1/Client/ReportErrorsServiceClient.php @@ -29,6 +29,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\ResourceHelperTrait; use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; @@ -148,25 +149,28 @@ public static function parseName(string $formattedName, ?string $template = null /** * Constructor. * - * @param array $options { + * @param array|ClientOptions $options { * Optional. Options for configuring the service API wrapper. * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted * as ":". Default 'clouderrorreporting.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * *Important*: If you accept a credential configuration (credential - * JSON/File/Stream) from an external source for authentication to Google Cloud - * Platform, you must validate it before providing it to any Google API or library. - * Providing an unvalidated credential configuration to Google APIs can compromise - * the security of your systems and data. For more information {@see + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\ErrorReporting\V1beta1\ReportErrorsServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new ReportErrorsServiceClient(['credentials' => $creds]); + * ``` + * {@see * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the @@ -204,13 +208,15 @@ public static function parseName(string $formattedName, ?string $template = null * @type false|LoggerInterface $logger * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. * } * * @throws ValidationException * * @experimental */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions);