diff --git a/Gax/README.md b/Gax/README.md index 2f5a1d9322c9..59e6d0665b2f 100644 --- a/Gax/README.md +++ b/Gax/README.md @@ -80,6 +80,8 @@ be found for Mac or Windows. > vendor/bin/phpunit ``` + For Showcase Conformance testing and client generation, see [tests/Conformance/README.md](tests/Conformance/README.md). + 4. Run static analysis tools ```sh diff --git a/Gax/tests/Conformance/README.md b/Gax/tests/Conformance/README.md new file mode 100644 index 000000000000..0858b2c77cf6 --- /dev/null +++ b/Gax/tests/Conformance/README.md @@ -0,0 +1,46 @@ +# GAX Showcase Conformance Testing + +This directory contains the integration conformance test suite (`ShowcaseTest.php`) and generated client SDK for `gapic-showcase`. + +## Prerequisites + +- **Protobuf Compiler (`protoc`)**: Ensure `protoc` is installed and available in your `$PATH`. +- **Dev Dependencies**: Ensure dev dependencies are installed: + ```sh + composer install -d dev/ + ``` + +## Generating the Showcase Client + +To generate or update the Showcase client SDK, message classes, and metadata using the PHP CLI tool: + +```sh +# From the repository root, run the console command: +./dev/google-cloud showcase:generate +``` + +Options: +- `-o, --out-dir `: Output directory relative to repository root (defaults to `Gax`). +- `-p, --showcase-path `: Path to local `gapic-showcase` repository (defaults to installed vendor dependency). +- `-g, --generator-path `: Path to local `gapic-generator-php` (defaults to installed vendor dependency). +- `-a, --googleapis-path `: Path to `googleapis` repository (defaults to submodule in `gapic-generator-php`). + +## Running Conformance Tests + +1. Install and launch the matching `gapic-showcase` mock server in the background: + ```sh + # Option 1 (curl) + curl -L https://github.com/googleapis/gapic-showcase/releases/download/v0.41.1/gapic-showcase-0.41.1-linux-amd64.tar.gz | tar -zx + ./gapic-showcase run & + + # Option 2 (go install) + go install github.com/googleapis/gapic-showcase/cmd/gapic-showcase@latest + gapic-showcase run & + ``` + +2. Run the PHPUnit conformance test suite: + ```sh + vendor/bin/phpunit -c Gax/phpunit-conformance.xml.dist + # or from the Gax directory: + cd Gax && vendor/bin/phpunit tests/Conformance/ShowcaseTest.php + ``` diff --git a/Gax/tests/Conformance/metadata/V1Beta1/Compliance.php b/Gax/tests/Conformance/metadata/V1Beta1/Compliance.php index 9dfe4416cf50..44b08cfb907d 100644 Binary files a/Gax/tests/Conformance/metadata/V1Beta1/Compliance.php and b/Gax/tests/Conformance/metadata/V1Beta1/Compliance.php differ diff --git a/Gax/tests/Conformance/metadata/V1Beta1/Identity.php b/Gax/tests/Conformance/metadata/V1Beta1/Identity.php index 8637df482fcc..ae410b67ffba 100644 Binary files a/Gax/tests/Conformance/metadata/V1Beta1/Identity.php and b/Gax/tests/Conformance/metadata/V1Beta1/Identity.php differ diff --git a/Gax/tests/Conformance/metadata/V1Beta1/Messaging.php b/Gax/tests/Conformance/metadata/V1Beta1/Messaging.php index 3b8b801a1b3f..491c1c261782 100644 Binary files a/Gax/tests/Conformance/metadata/V1Beta1/Messaging.php and b/Gax/tests/Conformance/metadata/V1Beta1/Messaging.php differ diff --git a/Gax/tests/Conformance/metadata/V1Beta1/PBEcho.php b/Gax/tests/Conformance/metadata/V1Beta1/PBEcho.php index a3ace5c606f4..2b57079a7cbc 100644 Binary files a/Gax/tests/Conformance/metadata/V1Beta1/PBEcho.php and b/Gax/tests/Conformance/metadata/V1Beta1/PBEcho.php differ diff --git a/Gax/tests/Conformance/metadata/V1Beta1/Sequence.php b/Gax/tests/Conformance/metadata/V1Beta1/Sequence.php index d2f1e57bc591..62564a168b45 100644 --- a/Gax/tests/Conformance/metadata/V1Beta1/Sequence.php +++ b/Gax/tests/Conformance/metadata/V1Beta1/Sequence.php @@ -67,27 +67,27 @@ public static function initOnce() { CreateStreamingSequenceRequestF streaming_sequence ( 2*.google.showcase.v1beta1.StreamingSequence"P AttemptSequenceRequest6 -name ( B(àAúA" - showcase.googleapis.com/Sequence"€ +name ( B(úA" + showcase.googleapis.com/SequenceàA"€ AttemptStreamingSequenceRequest? -name ( B1àAúA+ -)showcase.googleapis.com/StreamingSequence +name ( B1úA+ +)showcase.googleapis.com/StreamingSequenceàA last_fail_index (BàA"3 AttemptStreamingSequenceResponse content ( "X GetSequenceReportRequest< -name ( B.àAúA( -&showcase.googleapis.com/SequenceReport"j +name ( B.úA( +&showcase.googleapis.com/SequenceReportàA"j !GetStreamingSequenceReportRequestE -name ( B7àAúA1 -/showcase.googleapis.com/StreamingSequenceReport2ð +name ( B7úA1 +/showcase.googleapis.com/StreamingSequenceReportàA2ð SequenceService” -CreateSequence..google.showcase.v1beta1.CreateSequenceRequest!.google.showcase.v1beta1.Sequence"/ÚAsequence‚Óä“"/v1beta1/sequences:sequenceÌ -CreateStreamingSequence7.google.showcase.v1beta1.CreateStreamingSequenceRequest*.google.showcase.v1beta1.StreamingSequence"LÚAstreaming_sequence‚Óä“1"/v1beta1/streamingSequences:streaming_sequenceª -GetSequenceReport1.google.showcase.v1beta1.GetSequenceReportRequest\'.google.showcase.v1beta1.SequenceReport"9ÚAname‚Óä“,*/v1beta1/{name=sequences/*/sequenceReport}× -GetStreamingSequenceReport:.google.showcase.v1beta1.GetStreamingSequenceReportRequest0.google.showcase.v1beta1.StreamingSequenceReport"KÚAname‚Óä“>google.showcase.v1beta1.AttemptSequenceRequest */ class AttemptSequenceRequest extends \Google\Protobuf\Internal\Message @@ -18,19 +20,6 @@ class AttemptSequenceRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; - /** - * @param string $name Please see {@see SequenceServiceClient::sequenceName()} for help formatting this field. - * - * @return \Google\Showcase\V1beta1\AttemptSequenceRequest - * - * @experimental - */ - public static function build(string $name): self - { - return (new self()) - ->setName($name); - } - /** * Constructor. * diff --git a/Gax/tests/Conformance/src/V1beta1/AttemptStreamingSequenceRequest.php b/Gax/tests/Conformance/src/V1beta1/AttemptStreamingSequenceRequest.php index 9d9c65e5bb47..169810da4d4c 100644 --- a/Gax/tests/Conformance/src/V1beta1/AttemptStreamingSequenceRequest.php +++ b/Gax/tests/Conformance/src/V1beta1/AttemptStreamingSequenceRequest.php @@ -9,6 +9,8 @@ use Google\Protobuf\Internal\GPBUtil; /** + * Request message for the AttemptStreamingSequence method. + * * Generated from protobuf message google.showcase.v1beta1.AttemptStreamingSequenceRequest */ class AttemptStreamingSequenceRequest extends \Google\Protobuf\Internal\Message @@ -26,19 +28,6 @@ class AttemptStreamingSequenceRequest extends \Google\Protobuf\Internal\Message */ protected $last_fail_index = 0; - /** - * @param string $name Please see {@see SequenceServiceClient::streamingSequenceName()} for help formatting this field. - * - * @return \Google\Showcase\V1beta1\AttemptStreamingSequenceRequest - * - * @experimental - */ - public static function build(string $name): self - { - return (new self()) - ->setName($name); - } - /** * Constructor. * diff --git a/Gax/tests/Conformance/src/V1beta1/AttemptStreamingSequenceResponse.php b/Gax/tests/Conformance/src/V1beta1/AttemptStreamingSequenceResponse.php index 87caa59a51f1..d042dca59134 100644 --- a/Gax/tests/Conformance/src/V1beta1/AttemptStreamingSequenceResponse.php +++ b/Gax/tests/Conformance/src/V1beta1/AttemptStreamingSequenceResponse.php @@ -9,7 +9,7 @@ use Google\Protobuf\Internal\GPBUtil; /** - * The response message for the Echo methods. + * The response message for the AttemptStreamingSequence method. * * Generated from protobuf message google.showcase.v1beta1.AttemptStreamingSequenceResponse */ diff --git a/Gax/tests/Conformance/src/V1beta1/Client/ComplianceClient.php b/Gax/tests/Conformance/src/V1beta1/Client/ComplianceClient.php index 913c3456efec..90829232eaa3 100644 --- a/Gax/tests/Conformance/src/V1beta1/Client/ComplianceClient.php +++ b/Gax/tests/Conformance/src/V1beta1/Client/ComplianceClient.php @@ -1,6 +1,6 @@ :". Default 'localhost:7469: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\Showcase\V1beta1\ComplianceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new ComplianceClient(['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 @@ -158,13 +166,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); @@ -191,8 +201,6 @@ public function __call($method, $args) * * The async variant is {@see ComplianceClient::getEnumAsync()} . * - * @example samples/V1beta1/ComplianceClient/get_enum.php - * * @param EnumRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -220,8 +228,6 @@ public function getEnum(EnumRequest $request, array $callOptions = []): EnumResp * * The async variant is {@see ComplianceClient::repeatDataBodyAsync()} . * - * @example samples/V1beta1/ComplianceClient/repeat_data_body.php - * * @param RepeatRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -250,8 +256,6 @@ public function repeatDataBody(RepeatRequest $request, array $callOptions = []): * * The async variant is {@see ComplianceClient::repeatDataBodyInfoAsync()} . * - * @example samples/V1beta1/ComplianceClient/repeat_data_body_info.php - * * @param RepeatRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -278,8 +282,6 @@ public function repeatDataBodyInfo(RepeatRequest $request, array $callOptions = * * The async variant is {@see ComplianceClient::repeatDataBodyPatchAsync()} . * - * @example samples/V1beta1/ComplianceClient/repeat_data_body_patch.php - * * @param RepeatRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -306,8 +308,6 @@ public function repeatDataBodyPatch(RepeatRequest $request, array $callOptions = * * The async variant is {@see ComplianceClient::repeatDataBodyPutAsync()} . * - * @example samples/V1beta1/ComplianceClient/repeat_data_body_put.php - * * @param RepeatRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -334,8 +334,6 @@ public function repeatDataBodyPut(RepeatRequest $request, array $callOptions = [ * * The async variant is {@see ComplianceClient::repeatDataPathResourceAsync()} . * - * @example samples/V1beta1/ComplianceClient/repeat_data_path_resource.php - * * @param RepeatRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -363,8 +361,6 @@ public function repeatDataPathResource(RepeatRequest $request, array $callOption * The async variant is * {@see ComplianceClient::repeatDataPathTrailingResourceAsync()} . * - * @example samples/V1beta1/ComplianceClient/repeat_data_path_trailing_resource.php - * * @param RepeatRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -392,8 +388,6 @@ public function repeatDataPathTrailingResource(RepeatRequest $request, array $ca * * The async variant is {@see ComplianceClient::repeatDataQueryAsync()} . * - * @example samples/V1beta1/ComplianceClient/repeat_data_query.php - * * @param RepeatRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -422,8 +416,6 @@ public function repeatDataQuery(RepeatRequest $request, array $callOptions = []) * * The async variant is {@see ComplianceClient::repeatDataSimplePathAsync()} . * - * @example samples/V1beta1/ComplianceClient/repeat_data_simple_path.php - * * @param RepeatRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -455,8 +447,6 @@ public function repeatDataSimplePath(RepeatRequest $request, array $callOptions * * The async variant is {@see ComplianceClient::verifyEnumAsync()} . * - * @example samples/V1beta1/ComplianceClient/verify_enum.php - * * @param EnumResponse $request A request to house fields associated with the call. * @param array $callOptions { * Optional. diff --git a/Gax/tests/Conformance/src/V1beta1/Client/EchoClient.php b/Gax/tests/Conformance/src/V1beta1/Client/EchoClient.php index eab8a8bc2fd5..9cdd598311a0 100644 --- a/Gax/tests/Conformance/src/V1beta1/Client/EchoClient.php +++ b/Gax/tests/Conformance/src/V1beta1/Client/EchoClient.php @@ -1,6 +1,6 @@ failEchoWithDetailsAsync(FailEchoWithDetailsRequest $request, array $optionalArgs = []) * @method PromiseInterface pagedExpandAsync(PagedExpandRequest $request, array $optionalArgs = []) * @method PromiseInterface pagedExpandLegacyAsync(PagedExpandLegacyRequest $request, array $optionalArgs = []) - * @method PromiseInterface pagedExpandLegacyMappedAsync(PagedExpandRequest $request, array $optionalArgs = []) + * @method PromiseInterface pagedExpandLegacyMappedAsync(PagedExpandRequest $request, array $optionalArgs = []) * @method PromiseInterface waitAsync(WaitRequest $request, array $optionalArgs = []) */ final class EchoClient @@ -98,7 +103,11 @@ final class EchoClient /** The api version of the service */ private string $apiVersion = 'v1_20240408'; - /** The default scopes required by the service. */ + /** + * The default scopes required by the service. + * + * @internal + */ public static $serviceScopes = []; private $operationsClient; @@ -149,7 +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; @@ -177,25 +186,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 'localhost:7469: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\Showcase\V1beta1\EchoClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new EchoClient(['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 @@ -233,13 +245,15 @@ 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 * * @experimental */ - public function __construct(array $options = []) + public function __construct(array|ClientOptions $options = []) { $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); @@ -264,8 +278,6 @@ public function __call($method, $args) * * The async variant is {@see EchoClient::blockAsync()} . * - * @example samples/V1beta1/EchoClient/block.php - * * @param BlockRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -292,8 +304,6 @@ public function block(BlockRequest $request, array $callOptions = []): BlockResp * content back on the stream. This method showcases bidirectional * streaming RPCs. * - * @example samples/V1beta1/EchoClient/chat.php - * * @param array $callOptions { * Optional. * @@ -317,8 +327,6 @@ public function chat(array $callOptions = []): BidiStream * by the client, this method will return the a concatenation of the strings * passed to it. This method showcases client-side streaming RPCs. * - * @example samples/V1beta1/EchoClient/collect.php - * * @param array $callOptions { * Optional. * @@ -342,8 +350,6 @@ public function collect(array $callOptions = []): ClientStream * * The async variant is {@see EchoClient::echoAsync()} . * - * @example samples/V1beta1/EchoClient/echo.php - * * @param EchoRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -375,8 +381,6 @@ public function echo(EchoRequest $request, array $callOptions = []): EchoRespons * * The async variant is {@see EchoClient::echoErrorDetailsAsync()} . * - * @example samples/V1beta1/EchoClient/echo_error_details.php - * * @param EchoErrorDetailsRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -402,8 +406,6 @@ public function echoErrorDetails(EchoErrorDetailsRequest $request, array $callOp * This method splits the given content into words and will pass each word back * through the stream. This method showcases server-side streaming RPCs. * - * @example samples/V1beta1/EchoClient/expand.php - * * @param ExpandRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -412,7 +414,7 @@ public function echoErrorDetails(EchoErrorDetailsRequest $request, array $callOp * Timeout to use for this call. * } * - * @return ServerStream + * @return ServerStream * * @throws ApiException Thrown if the API call fails. * @@ -434,8 +436,6 @@ public function expand(ExpandRequest $request, array $callOptions = []): ServerS * * The async variant is {@see EchoClient::failEchoWithDetailsAsync()} . * - * @example samples/V1beta1/EchoClient/fail_echo_with_details.php - * * @param FailEchoWithDetailsRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -463,8 +463,6 @@ public function failEchoWithDetails(FailEchoWithDetailsRequest $request, array $ * * The async variant is {@see EchoClient::pagedExpandAsync()} . * - * @example samples/V1beta1/EchoClient/paged_expand.php - * * @param PagedExpandRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -493,8 +491,6 @@ public function pagedExpand(PagedExpandRequest $request, array $callOptions = [] * * The async variant is {@see EchoClient::pagedExpandLegacyAsync()} . * - * @example samples/V1beta1/EchoClient/paged_expand_legacy.php - * * @param PagedExpandLegacyRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -525,8 +521,6 @@ public function pagedExpandLegacy(PagedExpandLegacyRequest $request, array $call * * The async variant is {@see EchoClient::pagedExpandLegacyMappedAsync()} . * - * @example samples/V1beta1/EchoClient/paged_expand_legacy_mapped.php - * * @param PagedExpandRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -537,15 +531,15 @@ public function pagedExpandLegacy(PagedExpandLegacyRequest $request, array $call * {@see RetrySettings} for example usage. * } * - * @return PagedListResponse + * @return PagedExpandLegacyMappedResponse * * @throws ApiException Thrown if the API call fails. * * @experimental */ - public function pagedExpandLegacyMapped(PagedExpandRequest $request, array $callOptions = []): PagedListResponse + public function pagedExpandLegacyMapped(PagedExpandRequest $request, array $callOptions = []): PagedExpandLegacyMappedResponse { - return $this->startApiCall('PagedExpandLegacyMapped', $request, $callOptions); + return $this->startApiCall('PagedExpandLegacyMapped', $request, $callOptions)->wait(); } /** @@ -554,8 +548,6 @@ public function pagedExpandLegacyMapped(PagedExpandRequest $request, array $call * * The async variant is {@see EchoClient::waitAsync()} . * - * @example samples/V1beta1/EchoClient/wait.php - * * @param WaitRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -566,7 +558,7 @@ public function pagedExpandLegacyMapped(PagedExpandRequest $request, array $call * {@see RetrySettings} for example usage. * } * - * @return OperationResponse + * @return OperationResponse * * @throws ApiException Thrown if the API call fails. * diff --git a/Gax/tests/Conformance/src/V1beta1/Client/IdentityClient.php b/Gax/tests/Conformance/src/V1beta1/Client/IdentityClient.php index 01c047823a4c..34e35374484c 100644 --- a/Gax/tests/Conformance/src/V1beta1/Client/IdentityClient.php +++ b/Gax/tests/Conformance/src/V1beta1/Client/IdentityClient.php @@ -1,6 +1,6 @@ :". Default 'localhost:7469: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\Showcase\V1beta1\IdentityClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new IdentityClient(['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 +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); @@ -232,8 +242,6 @@ public function __call($method, $args) * * The async variant is {@see IdentityClient::createUserAsync()} . * - * @example samples/V1beta1/IdentityClient/create_user.php - * * @param CreateUserRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -260,8 +268,6 @@ public function createUser(CreateUserRequest $request, array $callOptions = []): * * The async variant is {@see IdentityClient::deleteUserAsync()} . * - * @example samples/V1beta1/IdentityClient/delete_user.php - * * @param DeleteUserRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -286,8 +292,6 @@ public function deleteUser(DeleteUserRequest $request, array $callOptions = []): * * The async variant is {@see IdentityClient::getUserAsync()} . * - * @example samples/V1beta1/IdentityClient/get_user.php - * * @param GetUserRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -314,8 +318,6 @@ public function getUser(GetUserRequest $request, array $callOptions = []): User * * The async variant is {@see IdentityClient::listUsersAsync()} . * - * @example samples/V1beta1/IdentityClient/list_users.php - * * @param ListUsersRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -342,8 +344,6 @@ public function listUsers(ListUsersRequest $request, array $callOptions = []): P * * The async variant is {@see IdentityClient::updateUserAsync()} . * - * @example samples/V1beta1/IdentityClient/update_user.php - * * @param UpdateUserRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. diff --git a/Gax/tests/Conformance/src/V1beta1/Client/MessagingClient.php b/Gax/tests/Conformance/src/V1beta1/Client/MessagingClient.php deleted file mode 100644 index 6acea6553826..000000000000 --- a/Gax/tests/Conformance/src/V1beta1/Client/MessagingClient.php +++ /dev/null @@ -1,833 +0,0 @@ - createBlurbAsync(CreateBlurbRequest $request, array $optionalArgs = []) - * @method PromiseInterface createRoomAsync(CreateRoomRequest $request, array $optionalArgs = []) - * @method PromiseInterface deleteBlurbAsync(DeleteBlurbRequest $request, array $optionalArgs = []) - * @method PromiseInterface deleteRoomAsync(DeleteRoomRequest $request, array $optionalArgs = []) - * @method PromiseInterface getBlurbAsync(GetBlurbRequest $request, array $optionalArgs = []) - * @method PromiseInterface getRoomAsync(GetRoomRequest $request, array $optionalArgs = []) - * @method PromiseInterface listBlurbsAsync(ListBlurbsRequest $request, array $optionalArgs = []) - * @method PromiseInterface listRoomsAsync(ListRoomsRequest $request, array $optionalArgs = []) - * @method PromiseInterface searchBlurbsAsync(SearchBlurbsRequest $request, array $optionalArgs = []) - * @method PromiseInterface updateBlurbAsync(UpdateBlurbRequest $request, array $optionalArgs = []) - * @method PromiseInterface updateRoomAsync(UpdateRoomRequest $request, array $optionalArgs = []) - */ -final class MessagingClient -{ - use GapicClientTrait; - use ResourceHelperTrait; - - /** The name of the service. */ - private const SERVICE_NAME = 'google.showcase.v1beta1.Messaging'; - - /** The default address of the service. */ - private const SERVICE_ADDRESS = 'localhost:7469'; - - /** The default port of the service. */ - private const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - private const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = []; - - private $operationsClient; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/messaging_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/messaging_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/messaging_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/messaging_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - * - * @experimental - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - * - * @experimental - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Create the default operation client for the service. - * - * @param array $options ClientOptions for the client. - * - * @return OperationsClient - */ - private function createOperationsClient(array $options) - { - // Unset client-specific configuration options - unset($options['serviceName'], $options['clientConfig'], $options['descriptorsConfigPath']); - - if (isset($options['operationsClient'])) { - return $options['operationsClient']; - } - - return new OperationsClient($options); - } - - /** - * Formats a string containing the fully-qualified path to represent a blurb - * resource. - * - * @param string $user - * @param string $blurb - * - * @return string The formatted blurb resource. - * - * @experimental - */ - public static function blurbName(string $user, string $blurb): string - { - return self::getPathTemplate('blurb')->render([ - 'user' => $user, - 'blurb' => $blurb, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a room - * resource. - * - * @param string $room - * - * @return string The formatted room resource. - * - * @experimental - */ - public static function roomName(string $room): string - { - return self::getPathTemplate('room')->render([ - 'room' => $room, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a room_blurb - * resource. - * - * @param string $room - * @param string $blurb - * - * @return string The formatted room_blurb resource. - * - * @experimental - */ - public static function roomBlurbName(string $room, string $blurb): string - { - return self::getPathTemplate('roomBlurb')->render([ - 'room' => $room, - 'blurb' => $blurb, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * room_legacy_room resource. - * - * @param string $room - * @param string $legacyRoom - * - * @return string The formatted room_legacy_room resource. - * - * @experimental - */ - public static function roomLegacyRoomName(string $room, string $legacyRoom): string - { - return self::getPathTemplate('roomLegacyRoom')->render([ - 'room' => $room, - 'legacy_room' => $legacyRoom, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * room_legacy_room_blurb resource. - * - * @param string $room - * @param string $legacyRoom - * @param string $blurb - * - * @return string The formatted room_legacy_room_blurb resource. - * - * @experimental - */ - public static function roomLegacyRoomBlurbName(string $room, string $legacyRoom, string $blurb): string - { - return self::getPathTemplate('roomLegacyRoomBlurb')->render([ - 'room' => $room, - 'legacy_room' => $legacyRoom, - 'blurb' => $blurb, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a user - * resource. - * - * @param string $user - * - * @return string The formatted user resource. - * - * @experimental - */ - public static function userName(string $user): string - { - return self::getPathTemplate('user')->render([ - 'user' => $user, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a user_blurb - * resource. - * - * @param string $user - * @param string $blurb - * - * @return string The formatted user_blurb resource. - * - * @experimental - */ - public static function userBlurbName(string $user, string $blurb): string - { - return self::getPathTemplate('userBlurb')->render([ - 'user' => $user, - 'blurb' => $blurb, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * user_blurb_legacy_user resource. - * - * @param string $user - * @param string $blurb - * @param string $legacyUser - * - * @return string The formatted user_blurb_legacy_user resource. - * - * @experimental - */ - public static function userBlurbLegacyUserName(string $user, string $blurb, string $legacyUser): string - { - return self::getPathTemplate('userBlurbLegacyUser')->render([ - 'user' => $user, - 'blurb' => $blurb, - 'legacy_user' => $legacyUser, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - blurb: users/{user}/blurbs/{blurb} - * - room: rooms/{room} - * - roomBlurb: rooms/{room}/blurbs/{blurb} - * - roomLegacyRoom: rooms/{room}/legacy_room/{legacy_room} - * - roomLegacyRoomBlurb: rooms/{room}/legacy_room/{legacy_room}/blurbs/{blurb} - * - user: users/{user} - * - userBlurb: users/{user}/blurbs/{blurb} - * - userBlurbLegacyUser: users/{user}/blurbs/{blurb}/legacy/{legacy_user} - * - * The optional $template argument can be supplied to specify a particular pattern, - * and must match one of the templates listed above. If no $template argument is - * provided, or if the $template argument does not match one of the templates - * listed, then parseName will check each of the supported templates, and return - * the first match. - * - * @param string $formattedName The formatted name string - * @param ?string $template Optional name of template to match - * - * @return array An associative array from name component IDs to component values. - * - * @throws ValidationException If $formattedName could not be matched. - * - * @experimental - */ - public static function parseName(string $formattedName, ?string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * Constructor. - * - * @param array $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 'localhost:7469: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 - * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} - * @type array $credentialsConfig - * Options used to configure credentials, including auth token caching, for the - * client. For a full list of supporting configuration options, see - * {@see \Google\ApiCore\CredentialsWrapper::build()} . - * @type bool $disableRetries - * Determines whether or not retries defined by the client configuration should be - * disabled. Defaults to `false`. - * @type string|array $clientConfig - * Client method configuration, including retry settings. This option can be either - * a path to a JSON file, or a PHP array containing the decoded JSON data. By - * default this settings points to the default client config file, which is - * provided in the resources folder. - * @type string|TransportInterface $transport - * The transport used for executing network requests. May be either the string - * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. - * *Advanced usage*: Additionally, it is possible to pass in an already - * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note - * that when this object is provided, any settings in $transportConfig, and any - * $apiEndpoint setting, will be ignored. - * @type array $transportConfig - * Configuration options that will be used to construct the transport. Options for - * each supported transport type should be passed in a key for that transport. For - * example: - * $transportConfig = [ - * 'grpc' => [...], - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and - * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the - * supported options. - * @type callable $clientCertSource - * A callable which returns the client cert as a string. This can be used to - * provide a certificate and private key to the transport layer for mTLS. - * @type false|LoggerInterface $logger - * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the - * 'GOOGLE_SDK_PHP_LOGGING' environment flag - * } - * - * @throws ValidationException - * - * @experimental - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * This method starts a bidirectional stream that receives all blurbs that - * are being created after the stream has started and sends requests to create - * blurbs. If an invalid blurb is requested to be created, the stream will - * close with an error. - * - * @example samples/V1beta1/MessagingClient/connect.php - * - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return BidiStream - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function connect(array $callOptions = []): BidiStream - { - return $this->startApiCall('Connect', null, $callOptions); - } - - /** - * Creates a blurb. If the parent is a room, the blurb is understood to be a - * message in that room. If the parent is a profile, the blurb is understood - * to be a post on the profile. - * - * The async variant is {@see MessagingClient::createBlurbAsync()} . - * - * @example samples/V1beta1/MessagingClient/create_blurb.php - * - * @param CreateBlurbRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return Blurb - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createBlurb(CreateBlurbRequest $request, array $callOptions = []): Blurb - { - return $this->startApiCall('CreateBlurb', $request, $callOptions)->wait(); - } - - /** - * Creates a room. - * - * The async variant is {@see MessagingClient::createRoomAsync()} . - * - * @example samples/V1beta1/MessagingClient/create_room.php - * - * @param CreateRoomRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return Room - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createRoom(CreateRoomRequest $request, array $callOptions = []): Room - { - return $this->startApiCall('CreateRoom', $request, $callOptions)->wait(); - } - - /** - * Deletes a blurb. - * - * The async variant is {@see MessagingClient::deleteBlurbAsync()} . - * - * @example samples/V1beta1/MessagingClient/delete_blurb.php - * - * @param DeleteBlurbRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteBlurb(DeleteBlurbRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteBlurb', $request, $callOptions)->wait(); - } - - /** - * Deletes a room and all of its blurbs. - * - * The async variant is {@see MessagingClient::deleteRoomAsync()} . - * - * @example samples/V1beta1/MessagingClient/delete_room.php - * - * @param DeleteRoomRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteRoom(DeleteRoomRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteRoom', $request, $callOptions)->wait(); - } - - /** - * Retrieves the Blurb with the given resource name. - * - * The async variant is {@see MessagingClient::getBlurbAsync()} . - * - * @example samples/V1beta1/MessagingClient/get_blurb.php - * - * @param GetBlurbRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return Blurb - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getBlurb(GetBlurbRequest $request, array $callOptions = []): Blurb - { - return $this->startApiCall('GetBlurb', $request, $callOptions)->wait(); - } - - /** - * Retrieves the Room with the given resource name. - * - * The async variant is {@see MessagingClient::getRoomAsync()} . - * - * @example samples/V1beta1/MessagingClient/get_room.php - * - * @param GetRoomRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return Room - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getRoom(GetRoomRequest $request, array $callOptions = []): Room - { - return $this->startApiCall('GetRoom', $request, $callOptions)->wait(); - } - - /** - * Lists blurbs for a specific chat room or user profile depending on the - * parent resource name. - * - * The async variant is {@see MessagingClient::listBlurbsAsync()} . - * - * @example samples/V1beta1/MessagingClient/list_blurbs.php - * - * @param ListBlurbsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listBlurbs(ListBlurbsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListBlurbs', $request, $callOptions); - } - - /** - * Lists all chat rooms. - * - * The async variant is {@see MessagingClient::listRoomsAsync()} . - * - * @example samples/V1beta1/MessagingClient/list_rooms.php - * - * @param ListRoomsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listRooms(ListRoomsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListRooms', $request, $callOptions); - } - - /** - * This method searches through all blurbs across all rooms and profiles - * for blurbs containing to words found in the query. Only posts that - * contain an exact match of a queried word will be returned. - * - * The async variant is {@see MessagingClient::searchBlurbsAsync()} . - * - * @example samples/V1beta1/MessagingClient/search_blurbs.php - * - * @param SearchBlurbsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return OperationResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function searchBlurbs(SearchBlurbsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SearchBlurbs', $request, $callOptions)->wait(); - } - - /** - * This is a stream to create multiple blurbs. If an invalid blurb is - * requested to be created, the stream will close with an error. - * - * @example samples/V1beta1/MessagingClient/send_blurbs.php - * - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return ClientStream - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function sendBlurbs(array $callOptions = []): ClientStream - { - return $this->startApiCall('SendBlurbs', null, $callOptions); - } - - /** - * This returns a stream that emits the blurbs that are created for a - * particular chat room or user profile. - * - * @example samples/V1beta1/MessagingClient/stream_blurbs.php - * - * @param StreamBlurbsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return ServerStream - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function streamBlurbs(StreamBlurbsRequest $request, array $callOptions = []): ServerStream - { - return $this->startApiCall('StreamBlurbs', $request, $callOptions); - } - - /** - * Updates a blurb. - * - * The async variant is {@see MessagingClient::updateBlurbAsync()} . - * - * @example samples/V1beta1/MessagingClient/update_blurb.php - * - * @param UpdateBlurbRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return Blurb - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function updateBlurb(UpdateBlurbRequest $request, array $callOptions = []): Blurb - { - return $this->startApiCall('UpdateBlurb', $request, $callOptions)->wait(); - } - - /** - * Updates a room. - * - * The async variant is {@see MessagingClient::updateRoomAsync()} . - * - * @example samples/V1beta1/MessagingClient/update_room.php - * - * @param UpdateRoomRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return Room - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function updateRoom(UpdateRoomRequest $request, array $callOptions = []): Room - { - return $this->startApiCall('UpdateRoom', $request, $callOptions)->wait(); - } -} diff --git a/Gax/tests/Conformance/src/V1beta1/Client/SequenceServiceClient.php b/Gax/tests/Conformance/src/V1beta1/Client/SequenceServiceClient.php index f5f8681d1c76..1021c5153a22 100644 --- a/Gax/tests/Conformance/src/V1beta1/Client/SequenceServiceClient.php +++ b/Gax/tests/Conformance/src/V1beta1/Client/SequenceServiceClient.php @@ -1,6 +1,6 @@ :". Default 'localhost:7469: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\Showcase\V1beta1\SequenceServiceClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new SequenceServiceClient(['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,13 +272,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); @@ -286,12 +298,10 @@ public function __call($method, $args) } /** - * Attempts a sequence. + * Attempts a sequence of unary responses. * * The async variant is {@see SequenceServiceClient::attemptSequenceAsync()} . * - * @example samples/V1beta1/SequenceServiceClient/attempt_sequence.php - * * @param AttemptSequenceRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -312,12 +322,11 @@ public function attemptSequence(AttemptSequenceRequest $request, array $callOpti } /** - * Attempts a streaming sequence. + * Attempts a server streaming call with a sequence of responses + * Can be used to test retries and stream resumption logic * May not function as expected in HTTP mode due to when http statuses are sent * See https://github.com/googleapis/gapic-showcase/issues/1377 for more details * - * @example samples/V1beta1/SequenceServiceClient/attempt_streaming_sequence.php - * * @param AttemptStreamingSequenceRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -326,7 +335,7 @@ public function attemptSequence(AttemptSequenceRequest $request, array $callOpti * Timeout to use for this call. * } * - * @return ServerStream + * @return ServerStream * * @throws ApiException Thrown if the API call fails. * @@ -338,12 +347,10 @@ public function attemptStreamingSequence(AttemptStreamingSequenceRequest $reques } /** - * Creates a sequence. + * Create a sequence of responses to be returned as unary calls * * The async variant is {@see SequenceServiceClient::createSequenceAsync()} . * - * @example samples/V1beta1/SequenceServiceClient/create_sequence.php - * * @param CreateSequenceRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -366,13 +373,11 @@ public function createSequence(CreateSequenceRequest $request, array $callOption } /** - * Creates a sequence. + * Creates a sequence of responses to be returned in a server streaming call * * The async variant is * {@see SequenceServiceClient::createStreamingSequenceAsync()} . * - * @example samples/V1beta1/SequenceServiceClient/create_streaming_sequence.php - * * @param CreateStreamingSequenceRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -395,12 +400,11 @@ public function createStreamingSequence(CreateStreamingSequenceRequest $request, } /** - * Retrieves a sequence. + * Retrieves a sequence report which can be used to retrieve information about a + * sequence of unary calls. * * The async variant is {@see SequenceServiceClient::getSequenceReportAsync()} . * - * @example samples/V1beta1/SequenceServiceClient/get_sequence_report.php - * * @param GetSequenceReportRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -423,13 +427,12 @@ public function getSequenceReport(GetSequenceReportRequest $request, array $call } /** - * Retrieves a sequence. + * Retrieves a sequence report which can be used to retrieve information + * about a sequences of responses in a server streaming call. * * The async variant is * {@see SequenceServiceClient::getStreamingSequenceReportAsync()} . * - * @example samples/V1beta1/SequenceServiceClient/get_streaming_sequence_report.php - * * @param GetStreamingSequenceReportRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. diff --git a/Gax/tests/Conformance/src/V1beta1/Client/TestingClient.php b/Gax/tests/Conformance/src/V1beta1/Client/TestingClient.php index 27f0778416a8..00b8ff916569 100644 --- a/Gax/tests/Conformance/src/V1beta1/Client/TestingClient.php +++ b/Gax/tests/Conformance/src/V1beta1/Client/TestingClient.php @@ -1,6 +1,6 @@ :". Default 'localhost:7469: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\Showcase\V1beta1\TestingClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new TestingClient(['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 @@ -236,13 +244,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); @@ -267,8 +277,6 @@ public function __call($method, $args) * * The async variant is {@see TestingClient::createSessionAsync()} . * - * @example samples/V1beta1/TestingClient/create_session.php - * * @param CreateSessionRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -295,8 +303,6 @@ public function createSession(CreateSessionRequest $request, array $callOptions * * The async variant is {@see TestingClient::deleteSessionAsync()} . * - * @example samples/V1beta1/TestingClient/delete_session.php - * * @param DeleteSessionRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -326,8 +332,6 @@ public function deleteSession(DeleteSessionRequest $request, array $callOptions * * The async variant is {@see TestingClient::deleteTestAsync()} . * - * @example samples/V1beta1/TestingClient/delete_test.php - * * @param DeleteTestRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -352,8 +356,6 @@ public function deleteTest(DeleteTestRequest $request, array $callOptions = []): * * The async variant is {@see TestingClient::getSessionAsync()} . * - * @example samples/V1beta1/TestingClient/get_session.php - * * @param GetSessionRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -380,8 +382,6 @@ public function getSession(GetSessionRequest $request, array $callOptions = []): * * The async variant is {@see TestingClient::listSessionsAsync()} . * - * @example samples/V1beta1/TestingClient/list_sessions.php - * * @param ListSessionsRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -408,8 +408,6 @@ public function listSessions(ListSessionsRequest $request, array $callOptions = * * The async variant is {@see TestingClient::listTestsAsync()} . * - * @example samples/V1beta1/TestingClient/list_tests.php - * * @param ListTestsRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -438,8 +436,6 @@ public function listTests(ListTestsRequest $request, array $callOptions = []): P * * The async variant is {@see TestingClient::reportSessionAsync()} . * - * @example samples/V1beta1/TestingClient/report_session.php - * * @param ReportSessionRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. @@ -469,8 +465,6 @@ public function reportSession(ReportSessionRequest $request, array $callOptions * * The async variant is {@see TestingClient::verifyTestAsync()} . * - * @example samples/V1beta1/TestingClient/verify_test.php - * * @param VerifyTestRequest $request A request to house fields associated with the call. * @param array $callOptions { * Optional. diff --git a/Gax/tests/Conformance/src/V1beta1/ComplianceData.php b/Gax/tests/Conformance/src/V1beta1/ComplianceData.php index 68891e78a876..b78a0112c62a 100644 --- a/Gax/tests/Conformance/src/V1beta1/ComplianceData.php +++ b/Gax/tests/Conformance/src/V1beta1/ComplianceData.php @@ -92,6 +92,46 @@ class ComplianceData extends \Google\Protobuf\Internal\Message * Generated from protobuf field optional int32 p_int32 = 18; */ protected $p_int32 = null; + /** + * Generated from protobuf field optional sint32 p_sint32 = 39; + */ + protected $p_sint32 = null; + /** + * Generated from protobuf field optional sfixed32 p_sfixed32 = 40; + */ + protected $p_sfixed32 = null; + /** + * Generated from protobuf field optional uint32 p_uint32 = 41; + */ + protected $p_uint32 = null; + /** + * Generated from protobuf field optional fixed32 p_fixed32 = 42; + */ + protected $p_fixed32 = null; + /** + * Generated from protobuf field optional int64 p_int64 = 43; + */ + protected $p_int64 = null; + /** + * Generated from protobuf field optional sint64 p_sint64 = 44; + */ + protected $p_sint64 = null; + /** + * Generated from protobuf field optional sfixed64 p_sfixed64 = 45; + */ + protected $p_sfixed64 = null; + /** + * Generated from protobuf field optional uint64 p_uint64 = 46; + */ + protected $p_uint64 = null; + /** + * Generated from protobuf field optional fixed64 p_fixed64 = 47; + */ + protected $p_fixed64 = null; + /** + * Generated from protobuf field optional float p_float = 48; + */ + protected $p_float = null; /** * Generated from protobuf field optional double p_double = 19; */ @@ -134,6 +174,16 @@ class ComplianceData extends \Google\Protobuf\Internal\Message * @type \Google\Showcase\V1beta1\ComplianceDataChild $f_child * @type string $p_string * @type int $p_int32 + * @type int $p_sint32 + * @type int $p_sfixed32 + * @type int $p_uint32 + * @type int $p_fixed32 + * @type int|string $p_int64 + * @type int|string $p_sint64 + * @type int|string $p_sfixed64 + * @type int|string $p_uint64 + * @type int|string $p_fixed64 + * @type float $p_float * @type float $p_double * @type bool $p_bool * @type int $p_kingdom @@ -593,6 +643,326 @@ public function setPInt32($var) return $this; } + /** + * Generated from protobuf field optional sint32 p_sint32 = 39; + * @return int + */ + public function getPSint32() + { + return isset($this->p_sint32) ? $this->p_sint32 : 0; + } + + public function hasPSint32() + { + return isset($this->p_sint32); + } + + public function clearPSint32() + { + unset($this->p_sint32); + } + + /** + * Generated from protobuf field optional sint32 p_sint32 = 39; + * @param int $var + * @return $this + */ + public function setPSint32($var) + { + GPBUtil::checkInt32($var); + $this->p_sint32 = $var; + + return $this; + } + + /** + * Generated from protobuf field optional sfixed32 p_sfixed32 = 40; + * @return int + */ + public function getPSfixed32() + { + return isset($this->p_sfixed32) ? $this->p_sfixed32 : 0; + } + + public function hasPSfixed32() + { + return isset($this->p_sfixed32); + } + + public function clearPSfixed32() + { + unset($this->p_sfixed32); + } + + /** + * Generated from protobuf field optional sfixed32 p_sfixed32 = 40; + * @param int $var + * @return $this + */ + public function setPSfixed32($var) + { + GPBUtil::checkInt32($var); + $this->p_sfixed32 = $var; + + return $this; + } + + /** + * Generated from protobuf field optional uint32 p_uint32 = 41; + * @return int + */ + public function getPUint32() + { + return isset($this->p_uint32) ? $this->p_uint32 : 0; + } + + public function hasPUint32() + { + return isset($this->p_uint32); + } + + public function clearPUint32() + { + unset($this->p_uint32); + } + + /** + * Generated from protobuf field optional uint32 p_uint32 = 41; + * @param int $var + * @return $this + */ + public function setPUint32($var) + { + GPBUtil::checkUint32($var); + $this->p_uint32 = $var; + + return $this; + } + + /** + * Generated from protobuf field optional fixed32 p_fixed32 = 42; + * @return int + */ + public function getPFixed32() + { + return isset($this->p_fixed32) ? $this->p_fixed32 : 0; + } + + public function hasPFixed32() + { + return isset($this->p_fixed32); + } + + public function clearPFixed32() + { + unset($this->p_fixed32); + } + + /** + * Generated from protobuf field optional fixed32 p_fixed32 = 42; + * @param int $var + * @return $this + */ + public function setPFixed32($var) + { + GPBUtil::checkUint32($var); + $this->p_fixed32 = $var; + + return $this; + } + + /** + * Generated from protobuf field optional int64 p_int64 = 43; + * @return int|string + */ + public function getPInt64() + { + return isset($this->p_int64) ? $this->p_int64 : 0; + } + + public function hasPInt64() + { + return isset($this->p_int64); + } + + public function clearPInt64() + { + unset($this->p_int64); + } + + /** + * Generated from protobuf field optional int64 p_int64 = 43; + * @param int|string $var + * @return $this + */ + public function setPInt64($var) + { + GPBUtil::checkInt64($var); + $this->p_int64 = $var; + + return $this; + } + + /** + * Generated from protobuf field optional sint64 p_sint64 = 44; + * @return int|string + */ + public function getPSint64() + { + return isset($this->p_sint64) ? $this->p_sint64 : 0; + } + + public function hasPSint64() + { + return isset($this->p_sint64); + } + + public function clearPSint64() + { + unset($this->p_sint64); + } + + /** + * Generated from protobuf field optional sint64 p_sint64 = 44; + * @param int|string $var + * @return $this + */ + public function setPSint64($var) + { + GPBUtil::checkInt64($var); + $this->p_sint64 = $var; + + return $this; + } + + /** + * Generated from protobuf field optional sfixed64 p_sfixed64 = 45; + * @return int|string + */ + public function getPSfixed64() + { + return isset($this->p_sfixed64) ? $this->p_sfixed64 : 0; + } + + public function hasPSfixed64() + { + return isset($this->p_sfixed64); + } + + public function clearPSfixed64() + { + unset($this->p_sfixed64); + } + + /** + * Generated from protobuf field optional sfixed64 p_sfixed64 = 45; + * @param int|string $var + * @return $this + */ + public function setPSfixed64($var) + { + GPBUtil::checkInt64($var); + $this->p_sfixed64 = $var; + + return $this; + } + + /** + * Generated from protobuf field optional uint64 p_uint64 = 46; + * @return int|string + */ + public function getPUint64() + { + return isset($this->p_uint64) ? $this->p_uint64 : 0; + } + + public function hasPUint64() + { + return isset($this->p_uint64); + } + + public function clearPUint64() + { + unset($this->p_uint64); + } + + /** + * Generated from protobuf field optional uint64 p_uint64 = 46; + * @param int|string $var + * @return $this + */ + public function setPUint64($var) + { + GPBUtil::checkUint64($var); + $this->p_uint64 = $var; + + return $this; + } + + /** + * Generated from protobuf field optional fixed64 p_fixed64 = 47; + * @return int|string + */ + public function getPFixed64() + { + return isset($this->p_fixed64) ? $this->p_fixed64 : 0; + } + + public function hasPFixed64() + { + return isset($this->p_fixed64); + } + + public function clearPFixed64() + { + unset($this->p_fixed64); + } + + /** + * Generated from protobuf field optional fixed64 p_fixed64 = 47; + * @param int|string $var + * @return $this + */ + public function setPFixed64($var) + { + GPBUtil::checkUint64($var); + $this->p_fixed64 = $var; + + return $this; + } + + /** + * Generated from protobuf field optional float p_float = 48; + * @return float + */ + public function getPFloat() + { + return isset($this->p_float) ? $this->p_float : 0.0; + } + + public function hasPFloat() + { + return isset($this->p_float); + } + + public function clearPFloat() + { + unset($this->p_float); + } + + /** + * Generated from protobuf field optional float p_float = 48; + * @param float $var + * @return $this + */ + public function setPFloat($var) + { + GPBUtil::checkFloat($var); + $this->p_float = $var; + + return $this; + } + /** * Generated from protobuf field optional double p_double = 19; * @return float diff --git a/Gax/tests/Conformance/src/V1beta1/CreateBlurbRequest.php b/Gax/tests/Conformance/src/V1beta1/CreateBlurbRequest.php index 2e591f68cbdc..8202d7120812 100644 --- a/Gax/tests/Conformance/src/V1beta1/CreateBlurbRequest.php +++ b/Gax/tests/Conformance/src/V1beta1/CreateBlurbRequest.php @@ -30,23 +30,6 @@ class CreateBlurbRequest extends \Google\Protobuf\Internal\Message */ protected $blurb = null; - /** - * @param string $parent The resource name of the chat room or user profile that this blurb will - * be tied to. Please see - * {@see MessagingClient::userName()} for help formatting this field. - * @param \Google\Showcase\V1beta1\Blurb $blurb The blurb to create. - * - * @return \Google\Showcase\V1beta1\CreateBlurbRequest - * - * @experimental - */ - public static function build(string $parent, \Google\Showcase\V1beta1\Blurb $blurb): self - { - return (new self()) - ->setParent($parent) - ->setBlurb($blurb); - } - /** * Constructor. * diff --git a/Gax/tests/Conformance/src/V1beta1/CreateRoomRequest.php b/Gax/tests/Conformance/src/V1beta1/CreateRoomRequest.php index e06b41262b2f..aa6100ebacb1 100644 --- a/Gax/tests/Conformance/src/V1beta1/CreateRoomRequest.php +++ b/Gax/tests/Conformance/src/V1beta1/CreateRoomRequest.php @@ -23,19 +23,6 @@ class CreateRoomRequest extends \Google\Protobuf\Internal\Message */ protected $room = null; - /** - * @param \Google\Showcase\V1beta1\Room $room The room to create. - * - * @return \Google\Showcase\V1beta1\CreateRoomRequest - * - * @experimental - */ - public static function build(\Google\Showcase\V1beta1\Room $room): self - { - return (new self()) - ->setRoom($room); - } - /** * Constructor. * diff --git a/Gax/tests/Conformance/src/V1beta1/CreateSequenceRequest.php b/Gax/tests/Conformance/src/V1beta1/CreateSequenceRequest.php index 824bb223a633..23f2c0a06e70 100644 --- a/Gax/tests/Conformance/src/V1beta1/CreateSequenceRequest.php +++ b/Gax/tests/Conformance/src/V1beta1/CreateSequenceRequest.php @@ -9,6 +9,8 @@ use Google\Protobuf\Internal\GPBUtil; /** + * Request message for creating a sequence of unary calls + * * Generated from protobuf message google.showcase.v1beta1.CreateSequenceRequest */ class CreateSequenceRequest extends \Google\Protobuf\Internal\Message @@ -18,19 +20,6 @@ class CreateSequenceRequest extends \Google\Protobuf\Internal\Message */ protected $sequence = null; - /** - * @param \Google\Showcase\V1beta1\Sequence $sequence - * - * @return \Google\Showcase\V1beta1\CreateSequenceRequest - * - * @experimental - */ - public static function build(\Google\Showcase\V1beta1\Sequence $sequence): self - { - return (new self()) - ->setSequence($sequence); - } - /** * Constructor. * diff --git a/Gax/tests/Conformance/src/V1beta1/CreateStreamingSequenceRequest.php b/Gax/tests/Conformance/src/V1beta1/CreateStreamingSequenceRequest.php index 60eaae273f4e..e724762df98d 100644 --- a/Gax/tests/Conformance/src/V1beta1/CreateStreamingSequenceRequest.php +++ b/Gax/tests/Conformance/src/V1beta1/CreateStreamingSequenceRequest.php @@ -9,6 +9,8 @@ use Google\Protobuf\Internal\GPBUtil; /** + * Request message for the sequences of responses to be sent in a server streaming call + * * Generated from protobuf message google.showcase.v1beta1.CreateStreamingSequenceRequest */ class CreateStreamingSequenceRequest extends \Google\Protobuf\Internal\Message @@ -18,19 +20,6 @@ class CreateStreamingSequenceRequest extends \Google\Protobuf\Internal\Message */ protected $streaming_sequence = null; - /** - * @param \Google\Showcase\V1beta1\StreamingSequence $streamingSequence - * - * @return \Google\Showcase\V1beta1\CreateStreamingSequenceRequest - * - * @experimental - */ - public static function build(\Google\Showcase\V1beta1\StreamingSequence $streamingSequence): self - { - return (new self()) - ->setStreamingSequence($streamingSequence); - } - /** * Constructor. * diff --git a/Gax/tests/Conformance/src/V1beta1/CreateUserRequest.php b/Gax/tests/Conformance/src/V1beta1/CreateUserRequest.php index 72af5e185bbc..8c7a8aca9f03 100644 --- a/Gax/tests/Conformance/src/V1beta1/CreateUserRequest.php +++ b/Gax/tests/Conformance/src/V1beta1/CreateUserRequest.php @@ -23,19 +23,6 @@ class CreateUserRequest extends \Google\Protobuf\Internal\Message */ protected $user = null; - /** - * @param \Google\Showcase\V1beta1\User $user The user to create. - * - * @return \Google\Showcase\V1beta1\CreateUserRequest - * - * @experimental - */ - public static function build(\Google\Showcase\V1beta1\User $user): self - { - return (new self()) - ->setUser($user); - } - /** * Constructor. * diff --git a/Gax/tests/Conformance/src/V1beta1/DeleteBlurbRequest.php b/Gax/tests/Conformance/src/V1beta1/DeleteBlurbRequest.php index 33d021c69a43..ce88e5fa80c1 100644 --- a/Gax/tests/Conformance/src/V1beta1/DeleteBlurbRequest.php +++ b/Gax/tests/Conformance/src/V1beta1/DeleteBlurbRequest.php @@ -23,20 +23,6 @@ class DeleteBlurbRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; - /** - * @param string $name The resource name of the requested blurb. Please see - * {@see MessagingClient::blurbName()} for help formatting this field. - * - * @return \Google\Showcase\V1beta1\DeleteBlurbRequest - * - * @experimental - */ - public static function build(string $name): self - { - return (new self()) - ->setName($name); - } - /** * Constructor. * diff --git a/Gax/tests/Conformance/src/V1beta1/DeleteRoomRequest.php b/Gax/tests/Conformance/src/V1beta1/DeleteRoomRequest.php index 7c5f4b83f76e..d0faf0a5d8b1 100644 --- a/Gax/tests/Conformance/src/V1beta1/DeleteRoomRequest.php +++ b/Gax/tests/Conformance/src/V1beta1/DeleteRoomRequest.php @@ -23,20 +23,6 @@ class DeleteRoomRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; - /** - * @param string $name The resource name of the requested room. Please see - * {@see MessagingClient::roomName()} for help formatting this field. - * - * @return \Google\Showcase\V1beta1\DeleteRoomRequest - * - * @experimental - */ - public static function build(string $name): self - { - return (new self()) - ->setName($name); - } - /** * Constructor. * diff --git a/Gax/tests/Conformance/src/V1beta1/DeleteUserRequest.php b/Gax/tests/Conformance/src/V1beta1/DeleteUserRequest.php index b0f77bf415f7..f711e3ac2ee9 100644 --- a/Gax/tests/Conformance/src/V1beta1/DeleteUserRequest.php +++ b/Gax/tests/Conformance/src/V1beta1/DeleteUserRequest.php @@ -23,20 +23,6 @@ class DeleteUserRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; - /** - * @param string $name The resource name of the user to delete. Please see - * {@see IdentityClient::userName()} for help formatting this field. - * - * @return \Google\Showcase\V1beta1\DeleteUserRequest - * - * @experimental - */ - public static function build(string $name): self - { - return (new self()) - ->setName($name); - } - /** * Constructor. * diff --git a/Gax/tests/Conformance/src/V1beta1/ExpandRequest.php b/Gax/tests/Conformance/src/V1beta1/ExpandRequest.php index ff777df17271..c7c7680878e3 100644 --- a/Gax/tests/Conformance/src/V1beta1/ExpandRequest.php +++ b/Gax/tests/Conformance/src/V1beta1/ExpandRequest.php @@ -34,21 +34,6 @@ class ExpandRequest extends \Google\Protobuf\Internal\Message */ protected $stream_wait_time = null; - /** - * @param string $content The content that will be split into words and returned on the stream. - * @param \Google\Rpc\Status $error The error that is thrown after all words are sent on the stream. - * - * @return \Google\Showcase\V1beta1\ExpandRequest - * - * @experimental - */ - public static function build(string $content, \Google\Rpc\Status $error): self - { - return (new self()) - ->setContent($content) - ->setError($error); - } - /** * Constructor. * diff --git a/Gax/tests/Conformance/src/V1beta1/GetBlurbRequest.php b/Gax/tests/Conformance/src/V1beta1/GetBlurbRequest.php index 5746c7116432..83b7a1978b5a 100644 --- a/Gax/tests/Conformance/src/V1beta1/GetBlurbRequest.php +++ b/Gax/tests/Conformance/src/V1beta1/GetBlurbRequest.php @@ -23,20 +23,6 @@ class GetBlurbRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; - /** - * @param string $name The resource name of the requested blurb. Please see - * {@see MessagingClient::blurbName()} for help formatting this field. - * - * @return \Google\Showcase\V1beta1\GetBlurbRequest - * - * @experimental - */ - public static function build(string $name): self - { - return (new self()) - ->setName($name); - } - /** * Constructor. * diff --git a/Gax/tests/Conformance/src/V1beta1/GetRoomRequest.php b/Gax/tests/Conformance/src/V1beta1/GetRoomRequest.php index f80ff9f40ea4..90b1a4715fce 100644 --- a/Gax/tests/Conformance/src/V1beta1/GetRoomRequest.php +++ b/Gax/tests/Conformance/src/V1beta1/GetRoomRequest.php @@ -23,20 +23,6 @@ class GetRoomRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; - /** - * @param string $name The resource name of the requested room. Please see - * {@see MessagingClient::roomName()} for help formatting this field. - * - * @return \Google\Showcase\V1beta1\GetRoomRequest - * - * @experimental - */ - public static function build(string $name): self - { - return (new self()) - ->setName($name); - } - /** * Constructor. * diff --git a/Gax/tests/Conformance/src/V1beta1/GetSequenceReportRequest.php b/Gax/tests/Conformance/src/V1beta1/GetSequenceReportRequest.php index 9cff8d1d607a..c33e199e0e73 100644 --- a/Gax/tests/Conformance/src/V1beta1/GetSequenceReportRequest.php +++ b/Gax/tests/Conformance/src/V1beta1/GetSequenceReportRequest.php @@ -18,19 +18,6 @@ class GetSequenceReportRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; - /** - * @param string $name Please see {@see SequenceServiceClient::sequenceReportName()} for help formatting this field. - * - * @return \Google\Showcase\V1beta1\GetSequenceReportRequest - * - * @experimental - */ - public static function build(string $name): self - { - return (new self()) - ->setName($name); - } - /** * Constructor. * diff --git a/Gax/tests/Conformance/src/V1beta1/GetStreamingSequenceReportRequest.php b/Gax/tests/Conformance/src/V1beta1/GetStreamingSequenceReportRequest.php index 8817ae7b93ff..e54ac620167f 100644 --- a/Gax/tests/Conformance/src/V1beta1/GetStreamingSequenceReportRequest.php +++ b/Gax/tests/Conformance/src/V1beta1/GetStreamingSequenceReportRequest.php @@ -18,19 +18,6 @@ class GetStreamingSequenceReportRequest extends \Google\Protobuf\Internal\Messag */ protected $name = ''; - /** - * @param string $name Please see {@see SequenceServiceClient::streamingSequenceReportName()} for help formatting this field. - * - * @return \Google\Showcase\V1beta1\GetStreamingSequenceReportRequest - * - * @experimental - */ - public static function build(string $name): self - { - return (new self()) - ->setName($name); - } - /** * Constructor. * diff --git a/Gax/tests/Conformance/src/V1beta1/GetUserRequest.php b/Gax/tests/Conformance/src/V1beta1/GetUserRequest.php index a10d124a1f61..3f26ad3432d4 100644 --- a/Gax/tests/Conformance/src/V1beta1/GetUserRequest.php +++ b/Gax/tests/Conformance/src/V1beta1/GetUserRequest.php @@ -23,20 +23,6 @@ class GetUserRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; - /** - * @param string $name The resource name of the requested user. Please see - * {@see IdentityClient::userName()} for help formatting this field. - * - * @return \Google\Showcase\V1beta1\GetUserRequest - * - * @experimental - */ - public static function build(string $name): self - { - return (new self()) - ->setName($name); - } - /** * Constructor. * diff --git a/Gax/tests/Conformance/src/V1beta1/ListBlurbsRequest.php b/Gax/tests/Conformance/src/V1beta1/ListBlurbsRequest.php index bd659054d7dc..2e71020fe5d6 100644 --- a/Gax/tests/Conformance/src/V1beta1/ListBlurbsRequest.php +++ b/Gax/tests/Conformance/src/V1beta1/ListBlurbsRequest.php @@ -39,20 +39,6 @@ class ListBlurbsRequest extends \Google\Protobuf\Internal\Message */ protected $page_token = ''; - /** - * @param string $parent The resource name of the requested room or profile who blurbs to list. Please see - * {@see MessagingClient::userName()} for help formatting this field. - * - * @return \Google\Showcase\V1beta1\ListBlurbsRequest - * - * @experimental - */ - public static function build(string $parent): self - { - return (new self()) - ->setParent($parent); - } - /** * Constructor. * diff --git a/Gax/tests/Conformance/src/V1beta1/PagedExpandLegacyMappedResponse.php b/Gax/tests/Conformance/src/V1beta1/PagedExpandLegacyMappedResponse.php index 4be88d99a26f..77d87f5ca6e6 100644 --- a/Gax/tests/Conformance/src/V1beta1/PagedExpandLegacyMappedResponse.php +++ b/Gax/tests/Conformance/src/V1beta1/PagedExpandLegacyMappedResponse.php @@ -18,7 +18,7 @@ class PagedExpandLegacyMappedResponse extends \Google\Protobuf\Internal\Message * (-- aip.dev/not-precedent: This is a legacy, non-standard pattern that violates * aip.dev/158. Ordinarily, this should be a `repeated` field, as in PagedExpandResponse. --) * - * Generated from protobuf field repeated .google.showcase.v1beta1.PagedExpandResponseList alphabetized = 1; + * Generated from protobuf field map alphabetized = 1; */ private $alphabetized; /** @@ -34,7 +34,7 @@ class PagedExpandLegacyMappedResponse extends \Google\Protobuf\Internal\Message * @param array $data { * Optional. Data for populating the Message object. * - * @type array<\Google\Showcase\V1beta1\PagedExpandResponseList>|\Google\Protobuf\Internal\RepeatedField $alphabetized + * @type array|\Google\Protobuf\Internal\MapField $alphabetized * The words that were expanded, indexed by their initial character. * (-- aip.dev/not-precedent: This is a legacy, non-standard pattern that violates * aip.dev/158. Ordinarily, this should be a `repeated` field, as in PagedExpandResponse. --) @@ -52,8 +52,8 @@ public function __construct($data = NULL) { * (-- aip.dev/not-precedent: This is a legacy, non-standard pattern that violates * aip.dev/158. Ordinarily, this should be a `repeated` field, as in PagedExpandResponse. --) * - * Generated from protobuf field repeated .google.showcase.v1beta1.PagedExpandResponseList alphabetized = 1; - * @return \Google\Protobuf\Internal\RepeatedField + * Generated from protobuf field map alphabetized = 1; + * @return \Google\Protobuf\Internal\MapField */ public function getAlphabetized() { @@ -65,13 +65,13 @@ public function getAlphabetized() * (-- aip.dev/not-precedent: This is a legacy, non-standard pattern that violates * aip.dev/158. Ordinarily, this should be a `repeated` field, as in PagedExpandResponse. --) * - * Generated from protobuf field repeated .google.showcase.v1beta1.PagedExpandResponseList alphabetized = 1; - * @param array<\Google\Showcase\V1beta1\PagedExpandResponseList>|\Google\Protobuf\Internal\RepeatedField $var + * Generated from protobuf field map alphabetized = 1; + * @param array|\Google\Protobuf\Internal\MapField $var * @return $this */ public function setAlphabetized($var) { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Showcase\V1beta1\PagedExpandResponseList::class); + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Showcase\V1beta1\PagedExpandResponseList::class); $this->alphabetized = $arr; return $this; diff --git a/Gax/tests/Conformance/src/V1beta1/SearchBlurbsRequest.php b/Gax/tests/Conformance/src/V1beta1/SearchBlurbsRequest.php index 984f508bf4cd..35cf83c8cc9e 100644 --- a/Gax/tests/Conformance/src/V1beta1/SearchBlurbsRequest.php +++ b/Gax/tests/Conformance/src/V1beta1/SearchBlurbsRequest.php @@ -48,23 +48,6 @@ class SearchBlurbsRequest extends \Google\Protobuf\Internal\Message */ protected $page_token = ''; - /** - * @param string $parent The rooms or profiles to search. If unset, `SearchBlurbs` will search all - * rooms and all profiles. - * @param string $query The query used to search for blurbs containing to words of this string. - * Only posts that contain an exact match of a queried word will be returned. - * - * @return \Google\Showcase\V1beta1\SearchBlurbsRequest - * - * @experimental - */ - public static function build(string $parent, string $query): self - { - return (new self()) - ->setParent($parent) - ->setQuery($query); - } - /** * Constructor. * diff --git a/Gax/tests/Conformance/src/V1beta1/Sequence.php b/Gax/tests/Conformance/src/V1beta1/Sequence.php index b8565b20374c..055b85bbbbec 100644 --- a/Gax/tests/Conformance/src/V1beta1/Sequence.php +++ b/Gax/tests/Conformance/src/V1beta1/Sequence.php @@ -9,6 +9,8 @@ use Google\Protobuf\Internal\GPBUtil; /** + * A sequence of responses to be returned in order for each unary call attempt + * * Generated from protobuf message google.showcase.v1beta1.Sequence */ class Sequence extends \Google\Protobuf\Internal\Message diff --git a/Gax/tests/Conformance/src/V1beta1/SequenceReport.php b/Gax/tests/Conformance/src/V1beta1/SequenceReport.php index 990664340637..adbe727d59f6 100644 --- a/Gax/tests/Conformance/src/V1beta1/SequenceReport.php +++ b/Gax/tests/Conformance/src/V1beta1/SequenceReport.php @@ -9,6 +9,8 @@ use Google\Protobuf\Internal\GPBUtil; /** + * A report of the results of a sequence of unary responses + * * Generated from protobuf message google.showcase.v1beta1.SequenceReport */ class SequenceReport extends \Google\Protobuf\Internal\Message diff --git a/Gax/tests/Conformance/src/V1beta1/StreamingSequence.php b/Gax/tests/Conformance/src/V1beta1/StreamingSequence.php index 4ee0a4047639..2bbcdaf9e43a 100644 --- a/Gax/tests/Conformance/src/V1beta1/StreamingSequence.php +++ b/Gax/tests/Conformance/src/V1beta1/StreamingSequence.php @@ -9,16 +9,22 @@ use Google\Protobuf\Internal\GPBUtil; /** + * A sequence of responses to be returned in order at the delay specified + * as part of the server streaming call + * * Generated from protobuf message google.showcase.v1beta1.StreamingSequence */ class StreamingSequence extends \Google\Protobuf\Internal\Message { /** + * The name of the streaming sequence. + * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ protected $name = ''; /** - * The Content that the stream will send + * The content that the stream will send + * this was specified when the sequence was created * * Generated from protobuf field string content = 2; */ @@ -38,8 +44,10 @@ class StreamingSequence extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $name + * The name of the streaming sequence. * @type string $content - * The Content that the stream will send + * The content that the stream will send + * this was specified when the sequence was created * @type array<\Google\Showcase\V1beta1\StreamingSequence\Response>|\Google\Protobuf\Internal\RepeatedField $responses * Sequence of responses to return in order for each attempt. If empty, the * default response is an immediate OK. @@ -51,6 +59,8 @@ public function __construct($data = NULL) { } /** + * The name of the streaming sequence. + * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @return string */ @@ -60,6 +70,8 @@ public function getName() } /** + * The name of the streaming sequence. + * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @param string $var * @return $this @@ -73,7 +85,8 @@ public function setName($var) } /** - * The Content that the stream will send + * The content that the stream will send + * this was specified when the sequence was created * * Generated from protobuf field string content = 2; * @return string @@ -84,7 +97,8 @@ public function getContent() } /** - * The Content that the stream will send + * The content that the stream will send + * this was specified when the sequence was created * * Generated from protobuf field string content = 2; * @param string $var diff --git a/Gax/tests/Conformance/src/V1beta1/StreamingSequence/Response.php b/Gax/tests/Conformance/src/V1beta1/StreamingSequence/Response.php index fde26643cd1e..4c5449e39226 100644 --- a/Gax/tests/Conformance/src/V1beta1/StreamingSequence/Response.php +++ b/Gax/tests/Conformance/src/V1beta1/StreamingSequence/Response.php @@ -28,7 +28,7 @@ class Response extends \Google\Protobuf\Internal\Message */ protected $delay = null; /** - * The index that the status should be sent + * The index that the status should be sent at * * Generated from protobuf field int32 response_index = 3; */ @@ -45,7 +45,7 @@ class Response extends \Google\Protobuf\Internal\Message * @type \Google\Protobuf\Duration $delay * The amount of time to delay sending the response. * @type int $response_index - * The index that the status should be sent + * The index that the status should be sent at * } */ public function __construct($data = NULL) { @@ -126,7 +126,7 @@ public function setDelay($var) } /** - * The index that the status should be sent + * The index that the status should be sent at * * Generated from protobuf field int32 response_index = 3; * @return int @@ -137,7 +137,7 @@ public function getResponseIndex() } /** - * The index that the status should be sent + * The index that the status should be sent at * * Generated from protobuf field int32 response_index = 3; * @param int $var diff --git a/Gax/tests/Conformance/src/V1beta1/StreamingSequenceReport.php b/Gax/tests/Conformance/src/V1beta1/StreamingSequenceReport.php index 6ed3e26d15e6..e475bbcd07a0 100644 --- a/Gax/tests/Conformance/src/V1beta1/StreamingSequenceReport.php +++ b/Gax/tests/Conformance/src/V1beta1/StreamingSequenceReport.php @@ -9,6 +9,8 @@ use Google\Protobuf\Internal\GPBUtil; /** + * A report of the results of a streaming sequence. + * * Generated from protobuf message google.showcase.v1beta1.StreamingSequenceReport */ class StreamingSequenceReport extends \Google\Protobuf\Internal\Message diff --git a/Gax/tests/Conformance/src/V1beta1/gapic_metadata.json b/Gax/tests/Conformance/src/V1beta1/gapic_metadata.json index ae1e9b817740..81aca6de4d64 100644 --- a/Gax/tests/Conformance/src/V1beta1/gapic_metadata.json +++ b/Gax/tests/Conformance/src/V1beta1/gapic_metadata.json @@ -126,7 +126,8 @@ } } } - } + }, + "apiVersion": "v1_20240408" }, "Identity": { "clients": { @@ -162,85 +163,6 @@ } } }, - "Messaging": { - "clients": { - "grpc": { - "libraryClient": "MessagingGapicClient", - "rpcs": { - "Connect": { - "methods": [ - "connect" - ] - }, - "CreateBlurb": { - "methods": [ - "createBlurb" - ] - }, - "CreateRoom": { - "methods": [ - "createRoom" - ] - }, - "DeleteBlurb": { - "methods": [ - "deleteBlurb" - ] - }, - "DeleteRoom": { - "methods": [ - "deleteRoom" - ] - }, - "GetBlurb": { - "methods": [ - "getBlurb" - ] - }, - "GetRoom": { - "methods": [ - "getRoom" - ] - }, - "ListBlurbs": { - "methods": [ - "listBlurbs" - ] - }, - "ListRooms": { - "methods": [ - "listRooms" - ] - }, - "SearchBlurbs": { - "methods": [ - "searchBlurbs" - ] - }, - "SendBlurbs": { - "methods": [ - "sendBlurbs" - ] - }, - "StreamBlurbs": { - "methods": [ - "streamBlurbs" - ] - }, - "UpdateBlurb": { - "methods": [ - "updateBlurb" - ] - }, - "UpdateRoom": { - "methods": [ - "updateRoom" - ] - } - } - } - } - }, "SequenceService": { "clients": { "grpc": { diff --git a/Gax/tests/Conformance/src/V1beta1/resources/compliance_descriptor_config.php b/Gax/tests/Conformance/src/V1beta1/resources/compliance_descriptor_config.php index e1e9126106fd..963e7dee225e 100644 --- a/Gax/tests/Conformance/src/V1beta1/resources/compliance_descriptor_config.php +++ b/Gax/tests/Conformance/src/V1beta1/resources/compliance_descriptor_config.php @@ -1,6 +1,6 @@ true, ]; diff --git a/Gax/tests/Conformance/src/V1beta1/resources/echo_descriptor_config.php b/Gax/tests/Conformance/src/V1beta1/resources/echo_descriptor_config.php index 63b503e5c1c5..784685cbba7c 100644 --- a/Gax/tests/Conformance/src/V1beta1/resources/echo_descriptor_config.php +++ b/Gax/tests/Conformance/src/V1beta1/resources/echo_descriptor_config.php @@ -1,6 +1,6 @@ [ + 'requestId' => \Google\Api\FieldInfo\Format::UUID4, + 'otherRequestId' => \Google\Api\FieldInfo\Format::UUID4, + ], ], 'EchoErrorDetails' => [ 'callType' => \Google\ApiCore\Call::UNARY_CALL, @@ -145,15 +149,7 @@ 'responseType' => 'Google\Showcase\V1beta1\PagedExpandResponse', ], 'PagedExpandLegacyMapped' => [ - 'pageStreaming' => [ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getAlphabetized', - ], - 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'callType' => \Google\ApiCore\Call::UNARY_CALL, 'responseType' => 'Google\Showcase\V1beta1\PagedExpandLegacyMappedResponse', ], ], diff --git a/Gax/tests/Conformance/src/V1beta1/resources/echo_rest_client_config.php b/Gax/tests/Conformance/src/V1beta1/resources/echo_rest_client_config.php index f1a999b60fbf..70b815644deb 100644 --- a/Gax/tests/Conformance/src/V1beta1/resources/echo_rest_client_config.php +++ b/Gax/tests/Conformance/src/V1beta1/resources/echo_rest_client_config.php @@ -1,6 +1,6 @@ true, ]; diff --git a/Gax/tests/Conformance/src/V1beta1/resources/identity_descriptor_config.php b/Gax/tests/Conformance/src/V1beta1/resources/identity_descriptor_config.php index b544be013f13..73b3f625e43a 100644 --- a/Gax/tests/Conformance/src/V1beta1/resources/identity_descriptor_config.php +++ b/Gax/tests/Conformance/src/V1beta1/resources/identity_descriptor_config.php @@ -1,6 +1,6 @@ true, ]; diff --git a/Gax/tests/Conformance/src/V1beta1/resources/messaging_client_config.json b/Gax/tests/Conformance/src/V1beta1/resources/messaging_client_config.json deleted file mode 100644 index 05a964f8f028..000000000000 --- a/Gax/tests/Conformance/src/V1beta1/resources/messaging_client_config.json +++ /dev/null @@ -1,109 +0,0 @@ -{ - "interfaces": { - "google.showcase.v1beta1.Messaging": { - "retry_codes": { - "no_retry_codes": [], - "no_retry_1_codes": [], - "retry_policy_1_codes": [ - "UNAVAILABLE", - "UNKNOWN" - ] - }, - "retry_params": { - "no_retry_params": { - "initial_retry_delay_millis": 0, - "retry_delay_multiplier": 0.0, - "max_retry_delay_millis": 0, - "initial_rpc_timeout_millis": 0, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 0, - "total_timeout_millis": 0 - }, - "no_retry_1_params": { - "initial_retry_delay_millis": 0, - "retry_delay_multiplier": 0.0, - "max_retry_delay_millis": 0, - "initial_rpc_timeout_millis": 5000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 5000, - "total_timeout_millis": 5000 - }, - "retry_policy_1_params": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 2.0, - "max_retry_delay_millis": 3000, - "initial_rpc_timeout_millis": 10000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 10000, - "total_timeout_millis": 10000 - } - }, - "methods": { - "Connect": { - "timeout_millis": 10000 - }, - "CreateBlurb": { - "timeout_millis": 5000, - "retry_codes_name": "no_retry_1_codes", - "retry_params_name": "no_retry_1_params" - }, - "CreateRoom": { - "timeout_millis": 5000, - "retry_codes_name": "no_retry_1_codes", - "retry_params_name": "no_retry_1_params" - }, - "DeleteBlurb": { - "timeout_millis": 5000, - "retry_codes_name": "no_retry_1_codes", - "retry_params_name": "no_retry_1_params" - }, - "DeleteRoom": { - "timeout_millis": 5000, - "retry_codes_name": "no_retry_1_codes", - "retry_params_name": "no_retry_1_params" - }, - "GetBlurb": { - "timeout_millis": 10000, - "retry_codes_name": "retry_policy_1_codes", - "retry_params_name": "retry_policy_1_params" - }, - "GetRoom": { - "timeout_millis": 10000, - "retry_codes_name": "retry_policy_1_codes", - "retry_params_name": "retry_policy_1_params" - }, - "ListBlurbs": { - "timeout_millis": 10000, - "retry_codes_name": "retry_policy_1_codes", - "retry_params_name": "retry_policy_1_params" - }, - "ListRooms": { - "timeout_millis": 10000, - "retry_codes_name": "retry_policy_1_codes", - "retry_params_name": "retry_policy_1_params" - }, - "SearchBlurbs": { - "timeout_millis": 10000, - "retry_codes_name": "retry_policy_1_codes", - "retry_params_name": "retry_policy_1_params" - }, - "SendBlurbs": { - "timeout_millis": 5000 - }, - "StreamBlurbs": { - "timeout_millis": 5000 - }, - "UpdateBlurb": { - "timeout_millis": 5000, - "retry_codes_name": "no_retry_1_codes", - "retry_params_name": "no_retry_1_params" - }, - "UpdateRoom": { - "timeout_millis": 5000, - "retry_codes_name": "no_retry_1_codes", - "retry_params_name": "no_retry_1_params" - } - } - } - } -} diff --git a/Gax/tests/Conformance/src/V1beta1/resources/messaging_descriptor_config.php b/Gax/tests/Conformance/src/V1beta1/resources/messaging_descriptor_config.php deleted file mode 100644 index f29f84658c63..000000000000 --- a/Gax/tests/Conformance/src/V1beta1/resources/messaging_descriptor_config.php +++ /dev/null @@ -1,216 +0,0 @@ - [ - 'google.showcase.v1beta1.Messaging' => [ - 'SearchBlurbs' => [ - 'longRunning' => [ - 'operationReturnType' => '\Google\Showcase\V1beta1\SearchBlurbsResponse', - 'metadataReturnType' => '\Google\Showcase\V1beta1\SearchBlurbsMetadata', - 'initialPollDelayMillis' => '500', - 'pollDelayMultiplier' => '1.5', - 'maxPollDelayMillis' => '5000', - 'totalPollTimeoutMillis' => '300000', - ], - 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, - 'headerParams' => [ - [ - 'keyName' => 'parent', - 'fieldAccessors' => [ - 'getParent', - ], - ], - ], - ], - 'Connect' => [ - 'grpcStreaming' => [ - 'grpcStreamingType' => 'BidiStreaming', - ], - 'callType' => \Google\ApiCore\Call::BIDI_STREAMING_CALL, - 'responseType' => 'Google\Showcase\V1beta1\StreamBlurbsResponse', - ], - 'CreateBlurb' => [ - 'callType' => \Google\ApiCore\Call::UNARY_CALL, - 'responseType' => 'Google\Showcase\V1beta1\Blurb', - 'headerParams' => [ - [ - 'keyName' => 'parent', - 'fieldAccessors' => [ - 'getParent', - ], - ], - ], - ], - 'CreateRoom' => [ - 'callType' => \Google\ApiCore\Call::UNARY_CALL, - 'responseType' => 'Google\Showcase\V1beta1\Room', - ], - 'DeleteBlurb' => [ - 'callType' => \Google\ApiCore\Call::UNARY_CALL, - 'responseType' => 'Google\Protobuf\GPBEmpty', - 'headerParams' => [ - [ - 'keyName' => 'name', - 'fieldAccessors' => [ - 'getName', - ], - ], - ], - ], - 'DeleteRoom' => [ - 'callType' => \Google\ApiCore\Call::UNARY_CALL, - 'responseType' => 'Google\Protobuf\GPBEmpty', - 'headerParams' => [ - [ - 'keyName' => 'name', - 'fieldAccessors' => [ - 'getName', - ], - ], - ], - ], - 'GetBlurb' => [ - 'callType' => \Google\ApiCore\Call::UNARY_CALL, - 'responseType' => 'Google\Showcase\V1beta1\Blurb', - 'headerParams' => [ - [ - 'keyName' => 'name', - 'fieldAccessors' => [ - 'getName', - ], - ], - ], - ], - 'GetRoom' => [ - 'callType' => \Google\ApiCore\Call::UNARY_CALL, - 'responseType' => 'Google\Showcase\V1beta1\Room', - 'headerParams' => [ - [ - 'keyName' => 'name', - 'fieldAccessors' => [ - 'getName', - ], - ], - ], - ], - 'ListBlurbs' => [ - 'pageStreaming' => [ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getBlurbs', - ], - 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, - 'responseType' => 'Google\Showcase\V1beta1\ListBlurbsResponse', - 'headerParams' => [ - [ - 'keyName' => 'parent', - 'fieldAccessors' => [ - 'getParent', - ], - ], - ], - ], - 'ListRooms' => [ - 'pageStreaming' => [ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getRooms', - ], - 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, - 'responseType' => 'Google\Showcase\V1beta1\ListRoomsResponse', - ], - 'SendBlurbs' => [ - 'grpcStreaming' => [ - 'grpcStreamingType' => 'ClientStreaming', - ], - 'callType' => \Google\ApiCore\Call::CLIENT_STREAMING_CALL, - 'responseType' => 'Google\Showcase\V1beta1\SendBlurbsResponse', - 'headerParams' => [ - [ - 'keyName' => 'parent', - 'fieldAccessors' => [ - 'getParent', - ], - ], - ], - ], - 'StreamBlurbs' => [ - 'grpcStreaming' => [ - 'grpcStreamingType' => 'ServerStreaming', - ], - 'callType' => \Google\ApiCore\Call::SERVER_STREAMING_CALL, - 'responseType' => 'Google\Showcase\V1beta1\StreamBlurbsResponse', - 'headerParams' => [ - [ - 'keyName' => 'name', - 'fieldAccessors' => [ - 'getName', - ], - ], - ], - ], - 'UpdateBlurb' => [ - 'callType' => \Google\ApiCore\Call::UNARY_CALL, - 'responseType' => 'Google\Showcase\V1beta1\Blurb', - 'headerParams' => [ - [ - 'keyName' => 'blurb.name', - 'fieldAccessors' => [ - 'getBlurb', - 'getName', - ], - ], - ], - ], - 'UpdateRoom' => [ - 'callType' => \Google\ApiCore\Call::UNARY_CALL, - 'responseType' => 'Google\Showcase\V1beta1\Room', - 'headerParams' => [ - [ - 'keyName' => 'room.name', - 'fieldAccessors' => [ - 'getRoom', - 'getName', - ], - ], - ], - ], - 'templateMap' => [ - 'blurb' => 'users/{user}/blurbs/{blurb}', - 'room' => 'rooms/{room}', - 'roomBlurb' => 'rooms/{room}/blurbs/{blurb}', - 'roomLegacyRoom' => 'rooms/{room}/legacy_room/{legacy_room}', - 'roomLegacyRoomBlurb' => 'rooms/{room}/legacy_room/{legacy_room}/blurbs/{blurb}', - 'user' => 'users/{user}', - 'userBlurb' => 'users/{user}/blurbs/{blurb}', - 'userBlurbLegacyUser' => 'users/{user}/blurbs/{blurb}/legacy/{legacy_user}', - ], - ], - ], -]; diff --git a/Gax/tests/Conformance/src/V1beta1/resources/messaging_rest_client_config.php b/Gax/tests/Conformance/src/V1beta1/resources/messaging_rest_client_config.php deleted file mode 100644 index 4b080078c321..000000000000 --- a/Gax/tests/Conformance/src/V1beta1/resources/messaging_rest_client_config.php +++ /dev/null @@ -1,349 +0,0 @@ - [ - 'google.cloud.location.Locations' => [ - 'ListLocations' => [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/{name=projects/*}/locations', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'GetLocation' => [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/{name=projects/*/locations/*}', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - ], - 'google.iam.v1.IAMPolicy' => [ - 'SetIamPolicy' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{resource=users/*}:setIamPolicy', - 'body' => '*', - 'additionalBindings' => [ - [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{resource=rooms/*}:setIamPolicy', - 'body' => '*', - ], - [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{resource=rooms/*/blurbs/*}:setIamPolicy', - 'body' => '*', - ], - [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{resource=sequences/*}:setIamPolicy', - 'body' => '*', - ], - ], - 'placeholders' => [ - 'resource' => [ - 'getters' => [ - 'getResource', - ], - ], - ], - ], - 'GetIamPolicy' => [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/{resource=users/*}:getIamPolicy', - 'additionalBindings' => [ - [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/{resource=rooms/*}:getIamPolicy', - ], - [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/{resource=rooms/*/blurbs/*}:getIamPolicy', - ], - [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/{resource=sequences/*}:getIamPolicy', - ], - ], - 'placeholders' => [ - 'resource' => [ - 'getters' => [ - 'getResource', - ], - ], - ], - ], - 'TestIamPermissions' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{resource=users/*}:testIamPermissions', - 'body' => '*', - 'additionalBindings' => [ - [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{resource=rooms/*}:testIamPermissions', - 'body' => '*', - ], - [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{resource=rooms/*/blurbs/*}:testIamPermissions', - 'body' => '*', - ], - [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{resource=sequences/*}:testIamPermissions', - 'body' => '*', - ], - ], - 'placeholders' => [ - 'resource' => [ - 'getters' => [ - 'getResource', - ], - ], - ], - ], - ], - 'google.longrunning.Operations' => [ - 'ListOperations' => [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/operations', - ], - 'GetOperation' => [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/{name=operations/**}', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'DeleteOperation' => [ - 'method' => 'delete', - 'uriTemplate' => '/v1beta1/{name=operations/**}', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'CancelOperation' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{name=operations/**}:cancel', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - ], - 'google.showcase.v1beta1.Messaging' => [ - 'CreateBlurb' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{parent=rooms/*}/blurbs', - 'body' => '*', - 'additionalBindings' => [ - [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{parent=users/*/profile}/blurbs', - 'body' => '*', - ], - ], - 'placeholders' => [ - 'parent' => [ - 'getters' => [ - 'getParent', - ], - ], - ], - ], - 'CreateRoom' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/rooms', - 'body' => '*', - ], - 'DeleteBlurb' => [ - 'method' => 'delete', - 'uriTemplate' => '/v1beta1/{name=rooms/*/blurbs/*}', - 'additionalBindings' => [ - [ - 'method' => 'delete', - 'uriTemplate' => '/v1beta1/{name=users/*/profile/blurbs/*}', - ], - ], - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'DeleteRoom' => [ - 'method' => 'delete', - 'uriTemplate' => '/v1beta1/{name=rooms/*}', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'GetBlurb' => [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/{name=rooms/*/blurbs/*}', - 'additionalBindings' => [ - [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/{name=users/*/profile/blurbs/*}', - ], - ], - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'GetRoom' => [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/{name=rooms/*}', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'ListBlurbs' => [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/{parent=rooms/*}/blurbs', - 'additionalBindings' => [ - [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/{parent=users/*/profile}/blurbs', - ], - ], - 'placeholders' => [ - 'parent' => [ - 'getters' => [ - 'getParent', - ], - ], - ], - ], - 'ListRooms' => [ - 'method' => 'get', - 'uriTemplate' => '/v1beta1/rooms', - ], - 'SearchBlurbs' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{parent=rooms/*}/blurbs:search', - 'body' => '*', - 'additionalBindings' => [ - [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{parent=users/*/profile}/blurbs:search', - 'body' => '*', - ], - ], - 'placeholders' => [ - 'parent' => [ - 'getters' => [ - 'getParent', - ], - ], - ], - ], - 'StreamBlurbs' => [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{name=rooms/*}/blurbs:stream', - 'body' => '*', - 'additionalBindings' => [ - [ - 'method' => 'post', - 'uriTemplate' => '/v1beta1/{name=users/*/profile}/blurbs:stream', - 'body' => '*', - ], - ], - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'UpdateBlurb' => [ - 'method' => 'patch', - 'uriTemplate' => '/v1beta1/{blurb.name=rooms/*/blurbs/*}', - 'body' => 'blurb', - 'additionalBindings' => [ - [ - 'method' => 'patch', - 'uriTemplate' => '/v1beta1/{blurb.name=users/*/profile/blurbs/*}', - 'body' => 'blurb', - ], - ], - 'placeholders' => [ - 'blurb.name' => [ - 'getters' => [ - 'getBlurb', - 'getName', - ], - ], - ], - ], - 'UpdateRoom' => [ - 'method' => 'patch', - 'uriTemplate' => '/v1beta1/{room.name=rooms/*}', - 'body' => 'room', - 'placeholders' => [ - 'room.name' => [ - 'getters' => [ - 'getRoom', - 'getName', - ], - ], - ], - ], - ], - ], - 'numericEnums' => true, -]; diff --git a/Gax/tests/Conformance/src/V1beta1/resources/sequence_service_descriptor_config.php b/Gax/tests/Conformance/src/V1beta1/resources/sequence_service_descriptor_config.php index 64096e0fe8bf..90bbf9d47dea 100644 --- a/Gax/tests/Conformance/src/V1beta1/resources/sequence_service_descriptor_config.php +++ b/Gax/tests/Conformance/src/V1beta1/resources/sequence_service_descriptor_config.php @@ -1,6 +1,6 @@ true, ]; diff --git a/Gax/tests/Conformance/src/V1beta1/resources/testing_descriptor_config.php b/Gax/tests/Conformance/src/V1beta1/resources/testing_descriptor_config.php index 6f62206cbe47..7b604c0134fe 100644 --- a/Gax/tests/Conformance/src/V1beta1/resources/testing_descriptor_config.php +++ b/Gax/tests/Conformance/src/V1beta1/resources/testing_descriptor_config.php @@ -1,6 +1,6 @@ true, ]; diff --git a/dev/composer.json b/dev/composer.json index 6c22b72e72a0..d462e10b3dd6 100644 --- a/dev/composer.json +++ b/dev/composer.json @@ -5,7 +5,7 @@ "php": ">=8.2", "vierbergenlars/php-semver": "^3.0", "symfony/console": " ^6.2", - "symfony/yaml": "^3.3||^6.0", + "symfony/yaml": "^3.3||^5.2||^6.0", "symfony/process": "^6.0", "google/cloud": "dev-parent", "symfony/filesystem": "^6.0", @@ -21,6 +21,8 @@ } }, "require-dev": { + "google/gapic-generator": "dev-main", + "google/gapic-showcase": "dev-main", "phpunit/phpunit": "^9.0", "phpspec/prophecy-phpunit": "^2.0", "swaggest/json-schema": "^0.12.0", @@ -37,6 +39,25 @@ "google/cloud": "dev-parent" } } + }, + "gapic-generator": { + "type": "vcs", + "url": "https://github.com/googleapis/gapic-generator-php.git", + "options": { + "submodules": true + } + }, + "gapic-showcase": { + "type": "package", + "package": { + "name": "google/gapic-showcase", + "version": "dev-main", + "source": { + "url": "https://github.com/googleapis/gapic-showcase.git", + "type": "git", + "reference": "main" + } + } } }, "config": { diff --git a/dev/google-cloud b/dev/google-cloud index 9ca23d233153..cf7e68d33daf 100755 --- a/dev/google-cloud +++ b/dev/google-cloud @@ -30,6 +30,7 @@ use Google\Cloud\Dev\Command\ComponentUpdateCommand; use Google\Cloud\Dev\Command\ComponentUpdateReadmeSampleCommand; use Google\Cloud\Dev\Command\ComponentUpdateDepsCommand; use Google\Cloud\Dev\Command\DocFxCommand; +use Google\Cloud\Dev\Command\ShowcaseGenerateCommand; use Google\Cloud\Dev\Command\ReleaseInfoCommand; use Google\Cloud\Dev\Command\ReleaseVerifyCommand; use Google\Cloud\Dev\Command\RepoComplianceCommand; @@ -55,6 +56,7 @@ $app->add(new ComponentUpdateCommand($rootDirectory)); $app->add(new ComponentUpdateReadmeSampleCommand($rootDirectory)); $app->add(new ComponentUpdateDepsCommand()); $app->add(new DocFxCommand()); +$app->add(new ShowcaseGenerateCommand($rootDirectory)); $app->add(new ReleaseInfoCommand()); $app->add(new ReleaseVerifyCommand()); $app->add(new RepoComplianceCommand()); diff --git a/dev/src/Command/ShowcaseGenerateCommand.php b/dev/src/Command/ShowcaseGenerateCommand.php new file mode 100644 index 000000000000..d3bc3518c782 --- /dev/null +++ b/dev/src/Command/ShowcaseGenerateCommand.php @@ -0,0 +1,249 @@ +rootDirectory = rtrim($rootDirectory, '/') . '/'; + $this->fs = new Filesystem(); + parent::__construct(); + } + + protected function configure() + { + $this->setName('showcase:generate') + ->setDescription('Generates the GAPIC Showcase client SDK for Conformance tests') + ->addOption( + 'out-dir', + 'o', + InputOption::VALUE_REQUIRED, + 'Output directory relative to root (defaults to Gax)', + 'Gax' + ) + ->addOption( + 'generator-path', + 'g', + InputOption::VALUE_REQUIRED, + 'Path to local gapic-generator repository (defaults to installed vendor dependency)' + ) + ->addOption( + 'showcase-path', + 'p', + InputOption::VALUE_REQUIRED, + 'Path to local gapic-showcase repository (defaults to installed vendor dependency)' + ) + ->addOption( + 'googleapis-path', + 'a', + InputOption::VALUE_REQUIRED, + 'Path to googleapis repository (defaults to submodule in gapic-generator)' + ); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $executableFinder = new ExecutableFinder(); + if (!$executableFinder->find('protoc')) { + $output->writeln('Error: protoc not found. Please install the protobuf compiler.'); + return Command::FAILURE; + } + + $outDir = $input->getOption('out-dir'); + $targetDir = $this->rootDirectory . trim($outDir, '/'); + $conformanceDir = $targetDir . '/tests/Conformance'; + $tmpOutputDir = $conformanceDir . '/tmp_out'; + $descFile = $conformanceDir . '/desc.pb'; + + // 1. Resolve Generator Path (Defaults to vendor dependency) + $generatorPath = $input->getOption('generator-path'); + if ($generatorPath) { + $generatorPath = rtrim($generatorPath, '/'); + if (file_exists($generatorPath . '/vendor/autoload.php')) { + require_once $generatorPath . '/vendor/autoload.php'; + } + $output->writeln("Using custom gapic-generator from: {$generatorPath}"); + } else { + if (is_dir($this->rootDirectory . 'dev/vendor/google/gapic-generator')) { + $generatorPath = $this->rootDirectory . 'dev/vendor/google/gapic-generator'; + } else { + $generatorPath = $this->rootDirectory . 'dev/vendor/google/gapic-generator-php'; + } + $output->writeln('Using installed gapic-generator dependency.'); + } + + // 2. Resolve Showcase Path (Defaults to vendor dependency) + $showcasePath = $input->getOption('showcase-path') ?: $this->rootDirectory . 'dev/vendor/google/gapic-showcase'; + if (!is_dir($showcasePath . '/schema/google/showcase/v1beta1')) { + $output->writeln("Error: gapic-showcase schema directory not found at {$showcasePath}."); + return Command::FAILURE; + } + $schemaDir = $showcasePath . '/schema/google/showcase/v1beta1'; + + // 3. Resolve Googleapis Path (Defaults to submodule in generatorPath) + $googleapisPath = $input->getOption('googleapis-path'); + if (!$googleapisPath) { + $submoduleGoogleapis = $generatorPath . '/googleapis'; + if (!file_exists($submoduleGoogleapis . '/google/cloud/common_resources.proto')) { + $output->writeln('Fetching googleapis definitions for gapic-generator...'); + if (is_dir($generatorPath . '/.git')) { + $this->runProcess(['git', 'submodule', 'update', '--init', '--recursive'], $generatorPath); + } else { + $this->runProcess(['git', 'clone', '--depth', '1', 'https://github.com/googleapis/googleapis.git', $submoduleGoogleapis]); + } + } + if (is_dir($submoduleGoogleapis . '/google/cloud')) { + $googleapisPath = $submoduleGoogleapis; + } + } + + if (!$googleapisPath || !is_dir($googleapisPath . '/google/cloud')) { + $output->writeln('Error: googleapis directory not found.'); + $output->writeln('Please specify the path using --googleapis-path '); + return Command::FAILURE; + } + + $output->writeln("Using output directory: {$targetDir}"); + $output->writeln("Using gapic-showcase schemas from: {$schemaDir}"); + $output->writeln("Using googleapis definitions from: {$googleapisPath}"); + + // 4. Clean up temporary outputs + $output->writeln('1. Cleaning up existing temporary outputs...'); + $this->fs->remove([$tmpOutputDir, $descFile]); + $this->fs->mkdir($tmpOutputDir . '/src'); + + // 5. Compile Proto Descriptor Set (desc.pb) + $output->writeln('2. Compiling proto descriptor set (desc.pb)...'); + $allProtoFiles = glob($schemaDir . '/*.proto'); + $generatorProtoFiles = array_values(array_filter( + $allProtoFiles, + fn ($file) => !str_ends_with($file, 'messaging.proto') + )); + + $protocDescCmd = array_merge([ + 'protoc', + '--include_imports', + '--include_source_info', + '-I', $showcasePath . '/schema', + '-I', $googleapisPath, + '--descriptor_set_out=' . $descFile, + ], $generatorProtoFiles, [ + $googleapisPath . '/google/cloud/common_resources.proto', + ]); + $this->runProcess($protocDescCmd); + + // 6. Generate Showcase PHP Client via CodeGenerator + $output->writeln('3. Generating Showcase PHP client (NEW_SURFACE_ONLY mode)...'); + + $descBytes = file_get_contents($descFile); + $grpcConfig = file_get_contents($schemaDir . '/showcase_grpc_service_config.json'); + + $serviceYaml = file_exists($schemaDir . '/showcase_v1beta1.yaml') ? file_get_contents($schemaDir . '/showcase_v1beta1.yaml') : null; + + $files = CodeGenerator::generateFromDescriptor( + $descBytes, + 'google.showcase.v1beta1', + 'grpc+rest', + true, + $grpcConfig, + null, + $serviceYaml, + false, + -1, + false, + MigrationMode::NEW_SURFACE_ONLY + ); + + foreach ($files as [$relPath, $content]) { + $fullPath = $tmpOutputDir . '/' . $relPath; + $this->fs->mkdir(dirname($fullPath)); + file_put_contents($fullPath, $content); + } + + // 7. Generate Protobuf Message Classes via protoc --php_out + $output->writeln('4. Generating Protobuf message classes...'); + $protocPhpCmd = array_merge([ + 'protoc', + '-I', $showcasePath . '/schema', + '-I', $googleapisPath, + '--php_out=' . $tmpOutputDir . '/src', + ], $allProtoFiles); + $this->runProcess($protocPhpCmd); + + // 8. Organize output into Conformance directory + $output->writeln('5. Organizing output into Conformance directory...'); + $this->fs->remove([$conformanceDir . '/src/V1beta1', $conformanceDir . '/metadata']); + $this->fs->mkdir([$conformanceDir . '/src/V1beta1/resources', $conformanceDir . '/metadata']); + + // Copy Client SDK classes + if (is_dir($tmpOutputDir . '/src/V1beta1')) { + $this->fs->mirror($tmpOutputDir . '/src/V1beta1', $conformanceDir . '/src/V1beta1'); + } + // Copy Protobuf Messages + if (is_dir($tmpOutputDir . '/src/Google/Showcase/V1beta1')) { + $this->fs->mirror($tmpOutputDir . '/src/Google/Showcase/V1beta1', $conformanceDir . '/src/V1beta1'); + } + // Copy REST configs + if (is_dir($tmpOutputDir . '/resources')) { + $this->fs->mirror($tmpOutputDir . '/resources', $conformanceDir . '/src/V1beta1/resources'); + } + // Copy Metadata preserving V1Beta1 directory casing + if (is_dir($tmpOutputDir . '/src/GPBMetadata/Google/Showcase')) { + $this->fs->mirror($tmpOutputDir . '/src/GPBMetadata/Google/Showcase', $conformanceDir . '/metadata'); + } + + // Exclude deprecated Protobuf flat alias files matching *_* (ignoring resources) + $deprecatedFinder = (new Finder())->files()->name('*_*.php')->in($conformanceDir . '/src/V1beta1')->notPath('resources'); + $this->fs->remove($deprecatedFinder); + + // 9. Clean up temporary files + $output->writeln('6. Cleaning up temporary files...'); + $this->fs->remove([$tmpOutputDir, $descFile]); + + $output->writeln("✅ Showcase Client generation complete! Output saved in: {$conformanceDir}"); + + return Command::SUCCESS; + } + + private function runProcess(array $command, ?string $cwd = null): void + { + $process = new Process($command, $cwd); + $process->setTimeout(300); + $process->mustRun(); + } +}