From b88dc2fe6dcb386e6775d3771a90bf8f652d4868 Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Fri, 21 Aug 2026 21:08:26 +0000 Subject: [PATCH 1/3] chore(Dataform): formatting fixes --- .../V1/DataformClient/cancel_operation.php | 78 ----- .../V1/DataformClient/delete_operation.php | 71 ----- .../V1/DataformClient/get_operation.php | 72 ----- .../V1/DataformClient/list_operations.php | 79 ----- .../DataformClient/cancel_operation.php | 78 ----- .../DataformClient/delete_operation.php | 71 ----- .../V1beta1/DataformClient/get_operation.php | 72 ----- .../DataformClient/list_operations.php | 79 ----- Dataform/src/V1/Client/DataformClient.php | 124 -------- Dataform/src/V1/gapic_metadata.json | 20 -- .../V1/resources/dataform_client_config.json | 20 -- .../resources/dataform_descriptor_config.php | 60 ---- .../src/V1beta1/Client/DataformClient.php | 132 --------- Dataform/src/V1beta1/gapic_metadata.json | 20 -- .../resources/dataform_client_config.json | 20 -- .../resources/dataform_descriptor_config.php | 60 ---- .../Unit/V1/Client/DataformClientTest.php | 270 ------------------ .../V1beta1/Client/DataformClientTest.php | 270 ------------------ 18 files changed, 1596 deletions(-) delete mode 100644 Dataform/samples/V1/DataformClient/cancel_operation.php delete mode 100644 Dataform/samples/V1/DataformClient/delete_operation.php delete mode 100644 Dataform/samples/V1/DataformClient/get_operation.php delete mode 100644 Dataform/samples/V1/DataformClient/list_operations.php delete mode 100644 Dataform/samples/V1beta1/DataformClient/cancel_operation.php delete mode 100644 Dataform/samples/V1beta1/DataformClient/delete_operation.php delete mode 100644 Dataform/samples/V1beta1/DataformClient/get_operation.php delete mode 100644 Dataform/samples/V1beta1/DataformClient/list_operations.php diff --git a/Dataform/samples/V1/DataformClient/cancel_operation.php b/Dataform/samples/V1/DataformClient/cancel_operation.php deleted file mode 100644 index 88eea448b836..000000000000 --- a/Dataform/samples/V1/DataformClient/cancel_operation.php +++ /dev/null @@ -1,78 +0,0 @@ -setName($name); - - // Call the API and handle any network failures. - try { - $dataformClient->cancelOperation($request); - printf('Call completed successfully.' . PHP_EOL); - } catch (ApiException $ex) { - printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); - } -} - -/** - * Helper to execute the sample. - * - * This sample has been automatically generated and should be regarded as a code - * template only. It will require modifications to work: - * - It may require correct/in-range values for request initialization. - * - It may require specifying regional endpoints when creating the service client, - * please see the apiEndpoint client configuration option for more details. - */ -function callSample(): void -{ - $name = '[NAME]'; - - cancel_operation_sample($name); -} -// [END dataform_v1_generated_Dataform_CancelOperation_sync] diff --git a/Dataform/samples/V1/DataformClient/delete_operation.php b/Dataform/samples/V1/DataformClient/delete_operation.php deleted file mode 100644 index ba2360391e47..000000000000 --- a/Dataform/samples/V1/DataformClient/delete_operation.php +++ /dev/null @@ -1,71 +0,0 @@ -setName($name); - - // Call the API and handle any network failures. - try { - $dataformClient->deleteOperation($request); - printf('Call completed successfully.' . PHP_EOL); - } catch (ApiException $ex) { - printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); - } -} - -/** - * Helper to execute the sample. - * - * This sample has been automatically generated and should be regarded as a code - * template only. It will require modifications to work: - * - It may require correct/in-range values for request initialization. - * - It may require specifying regional endpoints when creating the service client, - * please see the apiEndpoint client configuration option for more details. - */ -function callSample(): void -{ - $name = '[NAME]'; - - delete_operation_sample($name); -} -// [END dataform_v1_generated_Dataform_DeleteOperation_sync] diff --git a/Dataform/samples/V1/DataformClient/get_operation.php b/Dataform/samples/V1/DataformClient/get_operation.php deleted file mode 100644 index 4c3c465c9d30..000000000000 --- a/Dataform/samples/V1/DataformClient/get_operation.php +++ /dev/null @@ -1,72 +0,0 @@ -setName($name); - - // Call the API and handle any network failures. - try { - /** @var Operation $response */ - $response = $dataformClient->getOperation($request); - printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); - } catch (ApiException $ex) { - printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); - } -} - -/** - * Helper to execute the sample. - * - * This sample has been automatically generated and should be regarded as a code - * template only. It will require modifications to work: - * - It may require correct/in-range values for request initialization. - * - It may require specifying regional endpoints when creating the service client, - * please see the apiEndpoint client configuration option for more details. - */ -function callSample(): void -{ - $name = '[NAME]'; - - get_operation_sample($name); -} -// [END dataform_v1_generated_Dataform_GetOperation_sync] diff --git a/Dataform/samples/V1/DataformClient/list_operations.php b/Dataform/samples/V1/DataformClient/list_operations.php deleted file mode 100644 index c0dac88777de..000000000000 --- a/Dataform/samples/V1/DataformClient/list_operations.php +++ /dev/null @@ -1,79 +0,0 @@ -setName($name) - ->setFilter($filter); - - // Call the API and handle any network failures. - try { - /** @var PagedListResponse $response */ - $response = $dataformClient->listOperations($request); - - /** @var Operation $element */ - foreach ($response as $element) { - printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); - } - } catch (ApiException $ex) { - printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); - } -} - -/** - * Helper to execute the sample. - * - * This sample has been automatically generated and should be regarded as a code - * template only. It will require modifications to work: - * - It may require correct/in-range values for request initialization. - * - It may require specifying regional endpoints when creating the service client, - * please see the apiEndpoint client configuration option for more details. - */ -function callSample(): void -{ - $name = '[NAME]'; - $filter = '[FILTER]'; - - list_operations_sample($name, $filter); -} -// [END dataform_v1_generated_Dataform_ListOperations_sync] diff --git a/Dataform/samples/V1beta1/DataformClient/cancel_operation.php b/Dataform/samples/V1beta1/DataformClient/cancel_operation.php deleted file mode 100644 index 98fec49e0ca6..000000000000 --- a/Dataform/samples/V1beta1/DataformClient/cancel_operation.php +++ /dev/null @@ -1,78 +0,0 @@ -setName($name); - - // Call the API and handle any network failures. - try { - $dataformClient->cancelOperation($request); - printf('Call completed successfully.' . PHP_EOL); - } catch (ApiException $ex) { - printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); - } -} - -/** - * Helper to execute the sample. - * - * This sample has been automatically generated and should be regarded as a code - * template only. It will require modifications to work: - * - It may require correct/in-range values for request initialization. - * - It may require specifying regional endpoints when creating the service client, - * please see the apiEndpoint client configuration option for more details. - */ -function callSample(): void -{ - $name = '[NAME]'; - - cancel_operation_sample($name); -} -// [END dataform_v1beta1_generated_Dataform_CancelOperation_sync] diff --git a/Dataform/samples/V1beta1/DataformClient/delete_operation.php b/Dataform/samples/V1beta1/DataformClient/delete_operation.php deleted file mode 100644 index d2248dd0ed60..000000000000 --- a/Dataform/samples/V1beta1/DataformClient/delete_operation.php +++ /dev/null @@ -1,71 +0,0 @@ -setName($name); - - // Call the API and handle any network failures. - try { - $dataformClient->deleteOperation($request); - printf('Call completed successfully.' . PHP_EOL); - } catch (ApiException $ex) { - printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); - } -} - -/** - * Helper to execute the sample. - * - * This sample has been automatically generated and should be regarded as a code - * template only. It will require modifications to work: - * - It may require correct/in-range values for request initialization. - * - It may require specifying regional endpoints when creating the service client, - * please see the apiEndpoint client configuration option for more details. - */ -function callSample(): void -{ - $name = '[NAME]'; - - delete_operation_sample($name); -} -// [END dataform_v1beta1_generated_Dataform_DeleteOperation_sync] diff --git a/Dataform/samples/V1beta1/DataformClient/get_operation.php b/Dataform/samples/V1beta1/DataformClient/get_operation.php deleted file mode 100644 index afb61c1f8468..000000000000 --- a/Dataform/samples/V1beta1/DataformClient/get_operation.php +++ /dev/null @@ -1,72 +0,0 @@ -setName($name); - - // Call the API and handle any network failures. - try { - /** @var Operation $response */ - $response = $dataformClient->getOperation($request); - printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); - } catch (ApiException $ex) { - printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); - } -} - -/** - * Helper to execute the sample. - * - * This sample has been automatically generated and should be regarded as a code - * template only. It will require modifications to work: - * - It may require correct/in-range values for request initialization. - * - It may require specifying regional endpoints when creating the service client, - * please see the apiEndpoint client configuration option for more details. - */ -function callSample(): void -{ - $name = '[NAME]'; - - get_operation_sample($name); -} -// [END dataform_v1beta1_generated_Dataform_GetOperation_sync] diff --git a/Dataform/samples/V1beta1/DataformClient/list_operations.php b/Dataform/samples/V1beta1/DataformClient/list_operations.php deleted file mode 100644 index 8baf3219f54d..000000000000 --- a/Dataform/samples/V1beta1/DataformClient/list_operations.php +++ /dev/null @@ -1,79 +0,0 @@ -setName($name) - ->setFilter($filter); - - // Call the API and handle any network failures. - try { - /** @var PagedListResponse $response */ - $response = $dataformClient->listOperations($request); - - /** @var Operation $element */ - foreach ($response as $element) { - printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); - } - } catch (ApiException $ex) { - printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); - } -} - -/** - * Helper to execute the sample. - * - * This sample has been automatically generated and should be regarded as a code - * template only. It will require modifications to work: - * - It may require correct/in-range values for request initialization. - * - It may require specifying regional endpoints when creating the service client, - * please see the apiEndpoint client configuration option for more details. - */ -function callSample(): void -{ - $name = '[NAME]'; - $filter = '[FILTER]'; - - list_operations_sample($name, $filter); -} -// [END dataform_v1beta1_generated_Dataform_ListOperations_sync] diff --git a/Dataform/src/V1/Client/DataformClient.php b/Dataform/src/V1/Client/DataformClient.php index 9bd3ceee503e..e9b6cba17d67 100644 --- a/Dataform/src/V1/Client/DataformClient.php +++ b/Dataform/src/V1/Client/DataformClient.php @@ -142,11 +142,7 @@ use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; -use Google\LongRunning\CancelOperationRequest; use Google\LongRunning\Client\OperationsClient; -use Google\LongRunning\DeleteOperationRequest; -use Google\LongRunning\GetOperationRequest; -use Google\LongRunning\ListOperationsRequest; use Google\LongRunning\Operation; use GuzzleHttp\Promise\PromiseInterface; use Psr\Log\LoggerInterface; @@ -236,10 +232,6 @@ * @method PromiseInterface updateTeamFolderAsync(UpdateTeamFolderRequest $request, array $optionalArgs = []) * @method PromiseInterface updateWorkflowConfigAsync(UpdateWorkflowConfigRequest $request, array $optionalArgs = []) * @method PromiseInterface writeFileAsync(WriteFileRequest $request, array $optionalArgs = []) - * @method PromiseInterface cancelOperationAsync(CancelOperationRequest $request, array $optionalArgs = []) - * @method PromiseInterface deleteOperationAsync(DeleteOperationRequest $request, array $optionalArgs = []) - * @method PromiseInterface getOperationAsync(GetOperationRequest $request, array $optionalArgs = []) - * @method PromiseInterface listOperationsAsync(ListOperationsRequest $request, array $optionalArgs = []) * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ @@ -2786,122 +2778,6 @@ public function writeFile(WriteFileRequest $request, array $callOptions = []): W return $this->startApiCall('WriteFile', $request, $callOptions)->wait(); } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an [Operation.error][google.longrunning.Operation.error] value with a - * [google.rpc.Status.code][google.rpc.Status.code] of `1`, corresponding to - * `Code.CANCELLED`. - * - * The async variant is {@see DataformClient::cancelOperationAsync()} . - * - * @example samples/V1/DataformClient/cancel_operation.php - * - * @param CancelOperationRequest $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. - */ - public function cancelOperation(CancelOperationRequest $request, array $callOptions = []): void - { - $this->startApiCall('CancelOperation', $request, $callOptions)->wait(); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * The async variant is {@see DataformClient::deleteOperationAsync()} . - * - * @example samples/V1/DataformClient/delete_operation.php - * - * @param DeleteOperationRequest $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. - */ - public function deleteOperation(DeleteOperationRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteOperation', $request, $callOptions)->wait(); - } - - /** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * The async variant is {@see DataformClient::getOperationAsync()} . - * - * @example samples/V1/DataformClient/get_operation.php - * - * @param GetOperationRequest $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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function getOperation(GetOperationRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('GetOperation', $request, $callOptions)->wait(); - } - - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. - * - * The async variant is {@see DataformClient::listOperationsAsync()} . - * - * @example samples/V1/DataformClient/list_operations.php - * - * @param ListOperationsRequest $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. - */ - public function listOperations(ListOperationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListOperations', $request, $callOptions); - } - /** * Gets information about a location. * diff --git a/Dataform/src/V1/gapic_metadata.json b/Dataform/src/V1/gapic_metadata.json index 98e52bcd93d9..06e80d6b4b7e 100644 --- a/Dataform/src/V1/gapic_metadata.json +++ b/Dataform/src/V1/gapic_metadata.json @@ -375,26 +375,6 @@ "writeFile" ] }, - "CancelOperation": { - "methods": [ - "cancelOperation" - ] - }, - "DeleteOperation": { - "methods": [ - "deleteOperation" - ] - }, - "GetOperation": { - "methods": [ - "getOperation" - ] - }, - "ListOperations": { - "methods": [ - "listOperations" - ] - }, "GetLocation": { "methods": [ "getLocation" diff --git a/Dataform/src/V1/resources/dataform_client_config.json b/Dataform/src/V1/resources/dataform_client_config.json index 49882f361ea1..6613429c5650 100644 --- a/Dataform/src/V1/resources/dataform_client_config.json +++ b/Dataform/src/V1/resources/dataform_client_config.json @@ -393,26 +393,6 @@ "retry_codes_name": "no_retry_codes", "retry_params_name": "no_retry_params" }, - "CancelOperation": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - }, - "DeleteOperation": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - }, - "GetOperation": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - }, - "ListOperations": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - }, "GetLocation": { "timeout_millis": 60000, "retry_codes_name": "no_retry_codes", diff --git a/Dataform/src/V1/resources/dataform_descriptor_config.php b/Dataform/src/V1/resources/dataform_descriptor_config.php index e2824762585f..0897bbd6556f 100644 --- a/Dataform/src/V1/resources/dataform_descriptor_config.php +++ b/Dataform/src/V1/resources/dataform_descriptor_config.php @@ -1061,66 +1061,6 @@ ], ], ], - 'CancelOperation' => [ - 'callType' => \Google\ApiCore\Call::UNARY_CALL, - 'responseType' => 'Google\Protobuf\GPBEmpty', - 'headerParams' => [ - [ - 'keyName' => 'name', - 'fieldAccessors' => [ - 'getName', - ], - ], - ], - 'interfaceOverride' => 'google.longrunning.Operations', - ], - 'DeleteOperation' => [ - 'callType' => \Google\ApiCore\Call::UNARY_CALL, - 'responseType' => 'Google\Protobuf\GPBEmpty', - 'headerParams' => [ - [ - 'keyName' => 'name', - 'fieldAccessors' => [ - 'getName', - ], - ], - ], - 'interfaceOverride' => 'google.longrunning.Operations', - ], - 'GetOperation' => [ - 'callType' => \Google\ApiCore\Call::UNARY_CALL, - 'responseType' => 'Google\LongRunning\Operation', - 'headerParams' => [ - [ - 'keyName' => 'name', - 'fieldAccessors' => [ - 'getName', - ], - ], - ], - 'interfaceOverride' => 'google.longrunning.Operations', - ], - 'ListOperations' => [ - 'pageStreaming' => [ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getOperations', - ], - 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, - 'responseType' => 'Google\LongRunning\ListOperationsResponse', - 'headerParams' => [ - [ - 'keyName' => 'name', - 'fieldAccessors' => [ - 'getName', - ], - ], - ], - 'interfaceOverride' => 'google.longrunning.Operations', - ], 'GetLocation' => [ 'callType' => \Google\ApiCore\Call::UNARY_CALL, 'responseType' => 'Google\Cloud\Location\Location', diff --git a/Dataform/src/V1beta1/Client/DataformClient.php b/Dataform/src/V1beta1/Client/DataformClient.php index c7e72986bb2d..24018c7a44d4 100644 --- a/Dataform/src/V1beta1/Client/DataformClient.php +++ b/Dataform/src/V1beta1/Client/DataformClient.php @@ -154,11 +154,7 @@ use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; -use Google\LongRunning\CancelOperationRequest; use Google\LongRunning\Client\OperationsClient; -use Google\LongRunning\DeleteOperationRequest; -use Google\LongRunning\GetOperationRequest; -use Google\LongRunning\ListOperationsRequest; use Google\LongRunning\Operation; use GuzzleHttp\Promise\PromiseInterface; use Psr\Log\LoggerInterface; @@ -256,10 +252,6 @@ * @method PromiseInterface updateTeamFolderAsync(UpdateTeamFolderRequest $request, array $optionalArgs = []) * @method PromiseInterface updateWorkflowConfigAsync(UpdateWorkflowConfigRequest $request, array $optionalArgs = []) * @method PromiseInterface writeFileAsync(WriteFileRequest $request, array $optionalArgs = []) - * @method PromiseInterface cancelOperationAsync(CancelOperationRequest $request, array $optionalArgs = []) - * @method PromiseInterface deleteOperationAsync(DeleteOperationRequest $request, array $optionalArgs = []) - * @method PromiseInterface getOperationAsync(GetOperationRequest $request, array $optionalArgs = []) - * @method PromiseInterface listOperationsAsync(ListOperationsRequest $request, array $optionalArgs = []) * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ @@ -3164,130 +3156,6 @@ public function writeFile(WriteFileRequest $request, array $callOptions = []): W return $this->startApiCall('WriteFile', $request, $callOptions)->wait(); } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an [Operation.error][google.longrunning.Operation.error] value with a - * [google.rpc.Status.code][google.rpc.Status.code] of `1`, corresponding to - * `Code.CANCELLED`. - * - * The async variant is {@see DataformClient::cancelOperationAsync()} . - * - * @example samples/V1beta1/DataformClient/cancel_operation.php - * - * @param CancelOperationRequest $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 cancelOperation(CancelOperationRequest $request, array $callOptions = []): void - { - $this->startApiCall('CancelOperation', $request, $callOptions)->wait(); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * The async variant is {@see DataformClient::deleteOperationAsync()} . - * - * @example samples/V1beta1/DataformClient/delete_operation.php - * - * @param DeleteOperationRequest $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 deleteOperation(DeleteOperationRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteOperation', $request, $callOptions)->wait(); - } - - /** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * The async variant is {@see DataformClient::getOperationAsync()} . - * - * @example samples/V1beta1/DataformClient/get_operation.php - * - * @param GetOperationRequest $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 Operation - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getOperation(GetOperationRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('GetOperation', $request, $callOptions)->wait(); - } - - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. - * - * The async variant is {@see DataformClient::listOperationsAsync()} . - * - * @example samples/V1beta1/DataformClient/list_operations.php - * - * @param ListOperationsRequest $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 listOperations(ListOperationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListOperations', $request, $callOptions); - } - /** * Gets information about a location. * diff --git a/Dataform/src/V1beta1/gapic_metadata.json b/Dataform/src/V1beta1/gapic_metadata.json index dcee8b71f89f..d154bcb684f4 100644 --- a/Dataform/src/V1beta1/gapic_metadata.json +++ b/Dataform/src/V1beta1/gapic_metadata.json @@ -405,26 +405,6 @@ "writeFile" ] }, - "CancelOperation": { - "methods": [ - "cancelOperation" - ] - }, - "DeleteOperation": { - "methods": [ - "deleteOperation" - ] - }, - "GetOperation": { - "methods": [ - "getOperation" - ] - }, - "ListOperations": { - "methods": [ - "listOperations" - ] - }, "GetLocation": { "methods": [ "getLocation" diff --git a/Dataform/src/V1beta1/resources/dataform_client_config.json b/Dataform/src/V1beta1/resources/dataform_client_config.json index b78e7d1b30bf..baca07bf6625 100644 --- a/Dataform/src/V1beta1/resources/dataform_client_config.json +++ b/Dataform/src/V1beta1/resources/dataform_client_config.json @@ -423,26 +423,6 @@ "retry_codes_name": "no_retry_codes", "retry_params_name": "no_retry_params" }, - "CancelOperation": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - }, - "DeleteOperation": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - }, - "GetOperation": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - }, - "ListOperations": { - "timeout_millis": 60000, - "retry_codes_name": "no_retry_codes", - "retry_params_name": "no_retry_params" - }, "GetLocation": { "timeout_millis": 60000, "retry_codes_name": "no_retry_codes", diff --git a/Dataform/src/V1beta1/resources/dataform_descriptor_config.php b/Dataform/src/V1beta1/resources/dataform_descriptor_config.php index 1ce79f4abdc2..6764cb7d2cb2 100644 --- a/Dataform/src/V1beta1/resources/dataform_descriptor_config.php +++ b/Dataform/src/V1beta1/resources/dataform_descriptor_config.php @@ -1148,66 +1148,6 @@ ], ], ], - 'CancelOperation' => [ - 'callType' => \Google\ApiCore\Call::UNARY_CALL, - 'responseType' => 'Google\Protobuf\GPBEmpty', - 'headerParams' => [ - [ - 'keyName' => 'name', - 'fieldAccessors' => [ - 'getName', - ], - ], - ], - 'interfaceOverride' => 'google.longrunning.Operations', - ], - 'DeleteOperation' => [ - 'callType' => \Google\ApiCore\Call::UNARY_CALL, - 'responseType' => 'Google\Protobuf\GPBEmpty', - 'headerParams' => [ - [ - 'keyName' => 'name', - 'fieldAccessors' => [ - 'getName', - ], - ], - ], - 'interfaceOverride' => 'google.longrunning.Operations', - ], - 'GetOperation' => [ - 'callType' => \Google\ApiCore\Call::UNARY_CALL, - 'responseType' => 'Google\LongRunning\Operation', - 'headerParams' => [ - [ - 'keyName' => 'name', - 'fieldAccessors' => [ - 'getName', - ], - ], - ], - 'interfaceOverride' => 'google.longrunning.Operations', - ], - 'ListOperations' => [ - 'pageStreaming' => [ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getOperations', - ], - 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, - 'responseType' => 'Google\LongRunning\ListOperationsResponse', - 'headerParams' => [ - [ - 'keyName' => 'name', - 'fieldAccessors' => [ - 'getName', - ], - ], - ], - 'interfaceOverride' => 'google.longrunning.Operations', - ], 'GetLocation' => [ 'callType' => \Google\ApiCore\Call::UNARY_CALL, 'responseType' => 'Google\Cloud\Location\Location', diff --git a/Dataform/tests/Unit/V1/Client/DataformClientTest.php b/Dataform/tests/Unit/V1/Client/DataformClientTest.php index 753c3674c885..47c2b5d9370b 100644 --- a/Dataform/tests/Unit/V1/Client/DataformClientTest.php +++ b/Dataform/tests/Unit/V1/Client/DataformClientTest.php @@ -162,12 +162,8 @@ use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; -use Google\LongRunning\CancelOperationRequest; use Google\LongRunning\Client\OperationsClient; -use Google\LongRunning\DeleteOperationRequest; use Google\LongRunning\GetOperationRequest; -use Google\LongRunning\ListOperationsRequest; -use Google\LongRunning\ListOperationsResponse; use Google\LongRunning\Operation; use Google\Protobuf\Any; use Google\Protobuf\GPBEmpty; @@ -5758,272 +5754,6 @@ public function writeFileExceptionTest() $this->assertTrue($transport->isExhausted()); } - /** @test */ - public function cancelOperationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $name = 'name3373707'; - $request = (new CancelOperationRequest())->setName($name); - $gapicClient->cancelOperation($request); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/CancelOperation', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($name, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function cancelOperationExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode( - [ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], - JSON_PRETTY_PRINT - ); - $transport->addResponse(null, $status); - // Mock request - $name = 'name3373707'; - $request = (new CancelOperationRequest())->setName($name); - try { - $gapicClient->cancelOperation($request); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteOperationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $name = 'name3373707'; - $request = (new DeleteOperationRequest())->setName($name); - $gapicClient->deleteOperation($request); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/DeleteOperation', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($name, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteOperationExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode( - [ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], - JSON_PRETTY_PRINT - ); - $transport->addResponse(null, $status); - // Mock request - $name = 'name3373707'; - $request = (new DeleteOperationRequest())->setName($name); - try { - $gapicClient->deleteOperation($request); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getOperationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $done = true; - $expectedResponse = new Operation(); - $expectedResponse->setName($name2); - $expectedResponse->setDone($done); - $transport->addResponse($expectedResponse); - // Mock request - $name = 'name3373707'; - $request = (new GetOperationRequest())->setName($name); - $response = $gapicClient->getOperation($request); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/GetOperation', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($name, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getOperationExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode( - [ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], - JSON_PRETTY_PRINT - ); - $transport->addResponse(null, $status); - // Mock request - $name = 'name3373707'; - $request = (new GetOperationRequest())->setName($name); - try { - $gapicClient->getOperation($request); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listOperationsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $operationsElement = new Operation(); - $operations = [$operationsElement]; - $expectedResponse = new ListOperationsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setOperations($operations); - $transport->addResponse($expectedResponse); - // Mock request - $name = 'name3373707'; - $filter = 'filter-1274492040'; - $request = (new ListOperationsRequest())->setName($name)->setFilter($filter); - $response = $gapicClient->listOperations($request); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getOperations()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/ListOperations', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($name, $actualValue); - $actualValue = $actualRequestObject->getFilter(); - $this->assertProtobufEquals($filter, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listOperationsExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode( - [ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], - JSON_PRETTY_PRINT - ); - $transport->addResponse(null, $status); - // Mock request - $name = 'name3373707'; - $filter = 'filter-1274492040'; - $request = (new ListOperationsRequest())->setName($name)->setFilter($filter); - try { - $gapicClient->listOperations($request); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - /** @test */ public function getLocationTest() { diff --git a/Dataform/tests/Unit/V1beta1/Client/DataformClientTest.php b/Dataform/tests/Unit/V1beta1/Client/DataformClientTest.php index d2e5348ed1e1..2991bc31fe99 100644 --- a/Dataform/tests/Unit/V1beta1/Client/DataformClientTest.php +++ b/Dataform/tests/Unit/V1beta1/Client/DataformClientTest.php @@ -174,12 +174,8 @@ use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; -use Google\LongRunning\CancelOperationRequest; use Google\LongRunning\Client\OperationsClient; -use Google\LongRunning\DeleteOperationRequest; use Google\LongRunning\GetOperationRequest; -use Google\LongRunning\ListOperationsRequest; -use Google\LongRunning\ListOperationsResponse; use Google\LongRunning\Operation; use Google\Protobuf\Any; use Google\Protobuf\GPBEmpty; @@ -6243,272 +6239,6 @@ public function writeFileExceptionTest() $this->assertTrue($transport->isExhausted()); } - /** @test */ - public function cancelOperationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $name = 'name3373707'; - $request = (new CancelOperationRequest())->setName($name); - $gapicClient->cancelOperation($request); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/CancelOperation', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($name, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function cancelOperationExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode( - [ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], - JSON_PRETTY_PRINT - ); - $transport->addResponse(null, $status); - // Mock request - $name = 'name3373707'; - $request = (new CancelOperationRequest())->setName($name); - try { - $gapicClient->cancelOperation($request); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteOperationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $name = 'name3373707'; - $request = (new DeleteOperationRequest())->setName($name); - $gapicClient->deleteOperation($request); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/DeleteOperation', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($name, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteOperationExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode( - [ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], - JSON_PRETTY_PRINT - ); - $transport->addResponse(null, $status); - // Mock request - $name = 'name3373707'; - $request = (new DeleteOperationRequest())->setName($name); - try { - $gapicClient->deleteOperation($request); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getOperationTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $done = true; - $expectedResponse = new Operation(); - $expectedResponse->setName($name2); - $expectedResponse->setDone($done); - $transport->addResponse($expectedResponse); - // Mock request - $name = 'name3373707'; - $request = (new GetOperationRequest())->setName($name); - $response = $gapicClient->getOperation($request); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/GetOperation', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($name, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getOperationExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode( - [ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], - JSON_PRETTY_PRINT - ); - $transport->addResponse(null, $status); - // Mock request - $name = 'name3373707'; - $request = (new GetOperationRequest())->setName($name); - try { - $gapicClient->getOperation($request); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listOperationsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $operationsElement = new Operation(); - $operations = [$operationsElement]; - $expectedResponse = new ListOperationsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setOperations($operations); - $transport->addResponse($expectedResponse); - // Mock request - $name = 'name3373707'; - $filter = 'filter-1274492040'; - $request = (new ListOperationsRequest())->setName($name)->setFilter($filter); - $response = $gapicClient->listOperations($request); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getOperations()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/ListOperations', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($name, $actualValue); - $actualValue = $actualRequestObject->getFilter(); - $this->assertProtobufEquals($filter, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listOperationsExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode( - [ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], - JSON_PRETTY_PRINT - ); - $transport->addResponse(null, $status); - // Mock request - $name = 'name3373707'; - $filter = 'filter-1274492040'; - $request = (new ListOperationsRequest())->setName($name)->setFilter($filter); - try { - $gapicClient->listOperations($request); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - /** @test */ public function getLocationTest() { From 93bb7d5a7d54cec6373168757cff1ec4fe621326 Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Mon, 24 Aug 2026 23:47:29 +0000 Subject: [PATCH 2/3] fix: add operations.proto to dataform in librarian.yaml --- librarian.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/librarian.yaml b/librarian.yaml index e0dcfa80d119..04851edb8617 100644 --- a/librarian.yaml +++ b/librarian.yaml @@ -656,11 +656,13 @@ libraries: additional_protos: - google/cloud/location/locations.proto - google/iam/v1/iam_policy.proto + - google/longrunning/operations.proto - path: google/cloud/dataform/v1beta1 php: additional_protos: - google/cloud/location/locations.proto - google/iam/v1/iam_policy.proto + - google/longrunning/operations.proto output: Dataform - name: datafusion version: 1.2.0 From 835a088f85dde734400bd9c57e75edede3aa764c Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Mon, 24 Aug 2026 23:58:47 +0000 Subject: [PATCH 3/3] chore: recommit changes to 834 --- .../V1/DataformClient/cancel_operation.php | 78 +++++ .../V1/DataformClient/delete_operation.php | 71 +++++ .../V1/DataformClient/get_operation.php | 72 +++++ .../V1/DataformClient/list_operations.php | 79 +++++ .../DataformClient/cancel_operation.php | 78 +++++ .../DataformClient/delete_operation.php | 71 +++++ .../V1beta1/DataformClient/get_operation.php | 72 +++++ .../DataformClient/list_operations.php | 79 +++++ Dataform/src/V1/Client/DataformClient.php | 124 ++++++++ Dataform/src/V1/gapic_metadata.json | 20 ++ .../V1/resources/dataform_client_config.json | 20 ++ .../resources/dataform_descriptor_config.php | 60 ++++ .../src/V1beta1/Client/DataformClient.php | 132 +++++++++ Dataform/src/V1beta1/gapic_metadata.json | 20 ++ .../resources/dataform_client_config.json | 20 ++ .../resources/dataform_descriptor_config.php | 60 ++++ .../Unit/V1/Client/DataformClientTest.php | 270 ++++++++++++++++++ .../V1beta1/Client/DataformClientTest.php | 270 ++++++++++++++++++ 18 files changed, 1596 insertions(+) create mode 100644 Dataform/samples/V1/DataformClient/cancel_operation.php create mode 100644 Dataform/samples/V1/DataformClient/delete_operation.php create mode 100644 Dataform/samples/V1/DataformClient/get_operation.php create mode 100644 Dataform/samples/V1/DataformClient/list_operations.php create mode 100644 Dataform/samples/V1beta1/DataformClient/cancel_operation.php create mode 100644 Dataform/samples/V1beta1/DataformClient/delete_operation.php create mode 100644 Dataform/samples/V1beta1/DataformClient/get_operation.php create mode 100644 Dataform/samples/V1beta1/DataformClient/list_operations.php diff --git a/Dataform/samples/V1/DataformClient/cancel_operation.php b/Dataform/samples/V1/DataformClient/cancel_operation.php new file mode 100644 index 000000000000..88eea448b836 --- /dev/null +++ b/Dataform/samples/V1/DataformClient/cancel_operation.php @@ -0,0 +1,78 @@ +setName($name); + + // Call the API and handle any network failures. + try { + $dataformClient->cancelOperation($request); + printf('Call completed successfully.' . PHP_EOL); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $name = '[NAME]'; + + cancel_operation_sample($name); +} +// [END dataform_v1_generated_Dataform_CancelOperation_sync] diff --git a/Dataform/samples/V1/DataformClient/delete_operation.php b/Dataform/samples/V1/DataformClient/delete_operation.php new file mode 100644 index 000000000000..ba2360391e47 --- /dev/null +++ b/Dataform/samples/V1/DataformClient/delete_operation.php @@ -0,0 +1,71 @@ +setName($name); + + // Call the API and handle any network failures. + try { + $dataformClient->deleteOperation($request); + printf('Call completed successfully.' . PHP_EOL); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $name = '[NAME]'; + + delete_operation_sample($name); +} +// [END dataform_v1_generated_Dataform_DeleteOperation_sync] diff --git a/Dataform/samples/V1/DataformClient/get_operation.php b/Dataform/samples/V1/DataformClient/get_operation.php new file mode 100644 index 000000000000..4c3c465c9d30 --- /dev/null +++ b/Dataform/samples/V1/DataformClient/get_operation.php @@ -0,0 +1,72 @@ +setName($name); + + // Call the API and handle any network failures. + try { + /** @var Operation $response */ + $response = $dataformClient->getOperation($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $name = '[NAME]'; + + get_operation_sample($name); +} +// [END dataform_v1_generated_Dataform_GetOperation_sync] diff --git a/Dataform/samples/V1/DataformClient/list_operations.php b/Dataform/samples/V1/DataformClient/list_operations.php new file mode 100644 index 000000000000..c0dac88777de --- /dev/null +++ b/Dataform/samples/V1/DataformClient/list_operations.php @@ -0,0 +1,79 @@ +setName($name) + ->setFilter($filter); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $dataformClient->listOperations($request); + + /** @var Operation $element */ + foreach ($response as $element) { + printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $name = '[NAME]'; + $filter = '[FILTER]'; + + list_operations_sample($name, $filter); +} +// [END dataform_v1_generated_Dataform_ListOperations_sync] diff --git a/Dataform/samples/V1beta1/DataformClient/cancel_operation.php b/Dataform/samples/V1beta1/DataformClient/cancel_operation.php new file mode 100644 index 000000000000..98fec49e0ca6 --- /dev/null +++ b/Dataform/samples/V1beta1/DataformClient/cancel_operation.php @@ -0,0 +1,78 @@ +setName($name); + + // Call the API and handle any network failures. + try { + $dataformClient->cancelOperation($request); + printf('Call completed successfully.' . PHP_EOL); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $name = '[NAME]'; + + cancel_operation_sample($name); +} +// [END dataform_v1beta1_generated_Dataform_CancelOperation_sync] diff --git a/Dataform/samples/V1beta1/DataformClient/delete_operation.php b/Dataform/samples/V1beta1/DataformClient/delete_operation.php new file mode 100644 index 000000000000..d2248dd0ed60 --- /dev/null +++ b/Dataform/samples/V1beta1/DataformClient/delete_operation.php @@ -0,0 +1,71 @@ +setName($name); + + // Call the API and handle any network failures. + try { + $dataformClient->deleteOperation($request); + printf('Call completed successfully.' . PHP_EOL); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $name = '[NAME]'; + + delete_operation_sample($name); +} +// [END dataform_v1beta1_generated_Dataform_DeleteOperation_sync] diff --git a/Dataform/samples/V1beta1/DataformClient/get_operation.php b/Dataform/samples/V1beta1/DataformClient/get_operation.php new file mode 100644 index 000000000000..afb61c1f8468 --- /dev/null +++ b/Dataform/samples/V1beta1/DataformClient/get_operation.php @@ -0,0 +1,72 @@ +setName($name); + + // Call the API and handle any network failures. + try { + /** @var Operation $response */ + $response = $dataformClient->getOperation($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $name = '[NAME]'; + + get_operation_sample($name); +} +// [END dataform_v1beta1_generated_Dataform_GetOperation_sync] diff --git a/Dataform/samples/V1beta1/DataformClient/list_operations.php b/Dataform/samples/V1beta1/DataformClient/list_operations.php new file mode 100644 index 000000000000..8baf3219f54d --- /dev/null +++ b/Dataform/samples/V1beta1/DataformClient/list_operations.php @@ -0,0 +1,79 @@ +setName($name) + ->setFilter($filter); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $dataformClient->listOperations($request); + + /** @var Operation $element */ + foreach ($response as $element) { + printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $name = '[NAME]'; + $filter = '[FILTER]'; + + list_operations_sample($name, $filter); +} +// [END dataform_v1beta1_generated_Dataform_ListOperations_sync] diff --git a/Dataform/src/V1/Client/DataformClient.php b/Dataform/src/V1/Client/DataformClient.php index e9b6cba17d67..9bd3ceee503e 100644 --- a/Dataform/src/V1/Client/DataformClient.php +++ b/Dataform/src/V1/Client/DataformClient.php @@ -142,7 +142,11 @@ use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; +use Google\LongRunning\CancelOperationRequest; use Google\LongRunning\Client\OperationsClient; +use Google\LongRunning\DeleteOperationRequest; +use Google\LongRunning\GetOperationRequest; +use Google\LongRunning\ListOperationsRequest; use Google\LongRunning\Operation; use GuzzleHttp\Promise\PromiseInterface; use Psr\Log\LoggerInterface; @@ -232,6 +236,10 @@ * @method PromiseInterface updateTeamFolderAsync(UpdateTeamFolderRequest $request, array $optionalArgs = []) * @method PromiseInterface updateWorkflowConfigAsync(UpdateWorkflowConfigRequest $request, array $optionalArgs = []) * @method PromiseInterface writeFileAsync(WriteFileRequest $request, array $optionalArgs = []) + * @method PromiseInterface cancelOperationAsync(CancelOperationRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteOperationAsync(DeleteOperationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getOperationAsync(GetOperationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listOperationsAsync(ListOperationsRequest $request, array $optionalArgs = []) * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ @@ -2778,6 +2786,122 @@ public function writeFile(WriteFileRequest $request, array $callOptions = []): W return $this->startApiCall('WriteFile', $request, $callOptions)->wait(); } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an [Operation.error][google.longrunning.Operation.error] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of `1`, corresponding to + * `Code.CANCELLED`. + * + * The async variant is {@see DataformClient::cancelOperationAsync()} . + * + * @example samples/V1/DataformClient/cancel_operation.php + * + * @param CancelOperationRequest $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. + */ + public function cancelOperation(CancelOperationRequest $request, array $callOptions = []): void + { + $this->startApiCall('CancelOperation', $request, $callOptions)->wait(); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * The async variant is {@see DataformClient::deleteOperationAsync()} . + * + * @example samples/V1/DataformClient/delete_operation.php + * + * @param DeleteOperationRequest $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. + */ + public function deleteOperation(DeleteOperationRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteOperation', $request, $callOptions)->wait(); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * The async variant is {@see DataformClient::getOperationAsync()} . + * + * @example samples/V1/DataformClient/get_operation.php + * + * @param GetOperationRequest $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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function getOperation(GetOperationRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('GetOperation', $request, $callOptions)->wait(); + } + + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. + * + * The async variant is {@see DataformClient::listOperationsAsync()} . + * + * @example samples/V1/DataformClient/list_operations.php + * + * @param ListOperationsRequest $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. + */ + public function listOperations(ListOperationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListOperations', $request, $callOptions); + } + /** * Gets information about a location. * diff --git a/Dataform/src/V1/gapic_metadata.json b/Dataform/src/V1/gapic_metadata.json index 06e80d6b4b7e..98e52bcd93d9 100644 --- a/Dataform/src/V1/gapic_metadata.json +++ b/Dataform/src/V1/gapic_metadata.json @@ -375,6 +375,26 @@ "writeFile" ] }, + "CancelOperation": { + "methods": [ + "cancelOperation" + ] + }, + "DeleteOperation": { + "methods": [ + "deleteOperation" + ] + }, + "GetOperation": { + "methods": [ + "getOperation" + ] + }, + "ListOperations": { + "methods": [ + "listOperations" + ] + }, "GetLocation": { "methods": [ "getLocation" diff --git a/Dataform/src/V1/resources/dataform_client_config.json b/Dataform/src/V1/resources/dataform_client_config.json index 6613429c5650..49882f361ea1 100644 --- a/Dataform/src/V1/resources/dataform_client_config.json +++ b/Dataform/src/V1/resources/dataform_client_config.json @@ -393,6 +393,26 @@ "retry_codes_name": "no_retry_codes", "retry_params_name": "no_retry_params" }, + "CancelOperation": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "DeleteOperation": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "GetOperation": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "ListOperations": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, "GetLocation": { "timeout_millis": 60000, "retry_codes_name": "no_retry_codes", diff --git a/Dataform/src/V1/resources/dataform_descriptor_config.php b/Dataform/src/V1/resources/dataform_descriptor_config.php index 0897bbd6556f..e2824762585f 100644 --- a/Dataform/src/V1/resources/dataform_descriptor_config.php +++ b/Dataform/src/V1/resources/dataform_descriptor_config.php @@ -1061,6 +1061,66 @@ ], ], ], + 'CancelOperation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + 'interfaceOverride' => 'google.longrunning.Operations', + ], + 'DeleteOperation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + 'interfaceOverride' => 'google.longrunning.Operations', + ], + 'GetOperation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\LongRunning\Operation', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + 'interfaceOverride' => 'google.longrunning.Operations', + ], + 'ListOperations' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getOperations', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\LongRunning\ListOperationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + 'interfaceOverride' => 'google.longrunning.Operations', + ], 'GetLocation' => [ 'callType' => \Google\ApiCore\Call::UNARY_CALL, 'responseType' => 'Google\Cloud\Location\Location', diff --git a/Dataform/src/V1beta1/Client/DataformClient.php b/Dataform/src/V1beta1/Client/DataformClient.php index 24018c7a44d4..c7e72986bb2d 100644 --- a/Dataform/src/V1beta1/Client/DataformClient.php +++ b/Dataform/src/V1beta1/Client/DataformClient.php @@ -154,7 +154,11 @@ use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; +use Google\LongRunning\CancelOperationRequest; use Google\LongRunning\Client\OperationsClient; +use Google\LongRunning\DeleteOperationRequest; +use Google\LongRunning\GetOperationRequest; +use Google\LongRunning\ListOperationsRequest; use Google\LongRunning\Operation; use GuzzleHttp\Promise\PromiseInterface; use Psr\Log\LoggerInterface; @@ -252,6 +256,10 @@ * @method PromiseInterface updateTeamFolderAsync(UpdateTeamFolderRequest $request, array $optionalArgs = []) * @method PromiseInterface updateWorkflowConfigAsync(UpdateWorkflowConfigRequest $request, array $optionalArgs = []) * @method PromiseInterface writeFileAsync(WriteFileRequest $request, array $optionalArgs = []) + * @method PromiseInterface cancelOperationAsync(CancelOperationRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteOperationAsync(DeleteOperationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getOperationAsync(GetOperationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listOperationsAsync(ListOperationsRequest $request, array $optionalArgs = []) * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ @@ -3156,6 +3164,130 @@ public function writeFile(WriteFileRequest $request, array $callOptions = []): W return $this->startApiCall('WriteFile', $request, $callOptions)->wait(); } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an [Operation.error][google.longrunning.Operation.error] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of `1`, corresponding to + * `Code.CANCELLED`. + * + * The async variant is {@see DataformClient::cancelOperationAsync()} . + * + * @example samples/V1beta1/DataformClient/cancel_operation.php + * + * @param CancelOperationRequest $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 cancelOperation(CancelOperationRequest $request, array $callOptions = []): void + { + $this->startApiCall('CancelOperation', $request, $callOptions)->wait(); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * The async variant is {@see DataformClient::deleteOperationAsync()} . + * + * @example samples/V1beta1/DataformClient/delete_operation.php + * + * @param DeleteOperationRequest $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 deleteOperation(DeleteOperationRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteOperation', $request, $callOptions)->wait(); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * The async variant is {@see DataformClient::getOperationAsync()} . + * + * @example samples/V1beta1/DataformClient/get_operation.php + * + * @param GetOperationRequest $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 Operation + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getOperation(GetOperationRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('GetOperation', $request, $callOptions)->wait(); + } + + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. + * + * The async variant is {@see DataformClient::listOperationsAsync()} . + * + * @example samples/V1beta1/DataformClient/list_operations.php + * + * @param ListOperationsRequest $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 listOperations(ListOperationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListOperations', $request, $callOptions); + } + /** * Gets information about a location. * diff --git a/Dataform/src/V1beta1/gapic_metadata.json b/Dataform/src/V1beta1/gapic_metadata.json index d154bcb684f4..dcee8b71f89f 100644 --- a/Dataform/src/V1beta1/gapic_metadata.json +++ b/Dataform/src/V1beta1/gapic_metadata.json @@ -405,6 +405,26 @@ "writeFile" ] }, + "CancelOperation": { + "methods": [ + "cancelOperation" + ] + }, + "DeleteOperation": { + "methods": [ + "deleteOperation" + ] + }, + "GetOperation": { + "methods": [ + "getOperation" + ] + }, + "ListOperations": { + "methods": [ + "listOperations" + ] + }, "GetLocation": { "methods": [ "getLocation" diff --git a/Dataform/src/V1beta1/resources/dataform_client_config.json b/Dataform/src/V1beta1/resources/dataform_client_config.json index baca07bf6625..b78e7d1b30bf 100644 --- a/Dataform/src/V1beta1/resources/dataform_client_config.json +++ b/Dataform/src/V1beta1/resources/dataform_client_config.json @@ -423,6 +423,26 @@ "retry_codes_name": "no_retry_codes", "retry_params_name": "no_retry_params" }, + "CancelOperation": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "DeleteOperation": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "GetOperation": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "ListOperations": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, "GetLocation": { "timeout_millis": 60000, "retry_codes_name": "no_retry_codes", diff --git a/Dataform/src/V1beta1/resources/dataform_descriptor_config.php b/Dataform/src/V1beta1/resources/dataform_descriptor_config.php index 6764cb7d2cb2..1ce79f4abdc2 100644 --- a/Dataform/src/V1beta1/resources/dataform_descriptor_config.php +++ b/Dataform/src/V1beta1/resources/dataform_descriptor_config.php @@ -1148,6 +1148,66 @@ ], ], ], + 'CancelOperation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + 'interfaceOverride' => 'google.longrunning.Operations', + ], + 'DeleteOperation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + 'interfaceOverride' => 'google.longrunning.Operations', + ], + 'GetOperation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\LongRunning\Operation', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + 'interfaceOverride' => 'google.longrunning.Operations', + ], + 'ListOperations' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getOperations', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\LongRunning\ListOperationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + 'interfaceOverride' => 'google.longrunning.Operations', + ], 'GetLocation' => [ 'callType' => \Google\ApiCore\Call::UNARY_CALL, 'responseType' => 'Google\Cloud\Location\Location', diff --git a/Dataform/tests/Unit/V1/Client/DataformClientTest.php b/Dataform/tests/Unit/V1/Client/DataformClientTest.php index 47c2b5d9370b..753c3674c885 100644 --- a/Dataform/tests/Unit/V1/Client/DataformClientTest.php +++ b/Dataform/tests/Unit/V1/Client/DataformClientTest.php @@ -162,8 +162,12 @@ use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; +use Google\LongRunning\CancelOperationRequest; use Google\LongRunning\Client\OperationsClient; +use Google\LongRunning\DeleteOperationRequest; use Google\LongRunning\GetOperationRequest; +use Google\LongRunning\ListOperationsRequest; +use Google\LongRunning\ListOperationsResponse; use Google\LongRunning\Operation; use Google\Protobuf\Any; use Google\Protobuf\GPBEmpty; @@ -5754,6 +5758,272 @@ public function writeFileExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function cancelOperationTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $name = 'name3373707'; + $request = (new CancelOperationRequest())->setName($name); + $gapicClient->cancelOperation($request); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/CancelOperation', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($name, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function cancelOperationExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); + $transport->addResponse(null, $status); + // Mock request + $name = 'name3373707'; + $request = (new CancelOperationRequest())->setName($name); + try { + $gapicClient->cancelOperation($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteOperationTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $name = 'name3373707'; + $request = (new DeleteOperationRequest())->setName($name); + $gapicClient->deleteOperation($request); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/DeleteOperation', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($name, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteOperationExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); + $transport->addResponse(null, $status); + // Mock request + $name = 'name3373707'; + $request = (new DeleteOperationRequest())->setName($name); + try { + $gapicClient->deleteOperation($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getOperationTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $done = true; + $expectedResponse = new Operation(); + $expectedResponse->setName($name2); + $expectedResponse->setDone($done); + $transport->addResponse($expectedResponse); + // Mock request + $name = 'name3373707'; + $request = (new GetOperationRequest())->setName($name); + $response = $gapicClient->getOperation($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($name, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getOperationExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); + $transport->addResponse(null, $status); + // Mock request + $name = 'name3373707'; + $request = (new GetOperationRequest())->setName($name); + try { + $gapicClient->getOperation($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listOperationsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $operationsElement = new Operation(); + $operations = [$operationsElement]; + $expectedResponse = new ListOperationsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setOperations($operations); + $transport->addResponse($expectedResponse); + // Mock request + $name = 'name3373707'; + $filter = 'filter-1274492040'; + $request = (new ListOperationsRequest())->setName($name)->setFilter($filter); + $response = $gapicClient->listOperations($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getOperations()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/ListOperations', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($name, $actualValue); + $actualValue = $actualRequestObject->getFilter(); + $this->assertProtobufEquals($filter, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listOperationsExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); + $transport->addResponse(null, $status); + // Mock request + $name = 'name3373707'; + $filter = 'filter-1274492040'; + $request = (new ListOperationsRequest())->setName($name)->setFilter($filter); + try { + $gapicClient->listOperations($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + /** @test */ public function getLocationTest() { diff --git a/Dataform/tests/Unit/V1beta1/Client/DataformClientTest.php b/Dataform/tests/Unit/V1beta1/Client/DataformClientTest.php index 2991bc31fe99..d2e5348ed1e1 100644 --- a/Dataform/tests/Unit/V1beta1/Client/DataformClientTest.php +++ b/Dataform/tests/Unit/V1beta1/Client/DataformClientTest.php @@ -174,8 +174,12 @@ use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; +use Google\LongRunning\CancelOperationRequest; use Google\LongRunning\Client\OperationsClient; +use Google\LongRunning\DeleteOperationRequest; use Google\LongRunning\GetOperationRequest; +use Google\LongRunning\ListOperationsRequest; +use Google\LongRunning\ListOperationsResponse; use Google\LongRunning\Operation; use Google\Protobuf\Any; use Google\Protobuf\GPBEmpty; @@ -6239,6 +6243,272 @@ public function writeFileExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function cancelOperationTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $name = 'name3373707'; + $request = (new CancelOperationRequest())->setName($name); + $gapicClient->cancelOperation($request); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/CancelOperation', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($name, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function cancelOperationExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); + $transport->addResponse(null, $status); + // Mock request + $name = 'name3373707'; + $request = (new CancelOperationRequest())->setName($name); + try { + $gapicClient->cancelOperation($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteOperationTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $name = 'name3373707'; + $request = (new DeleteOperationRequest())->setName($name); + $gapicClient->deleteOperation($request); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/DeleteOperation', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($name, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteOperationExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); + $transport->addResponse(null, $status); + // Mock request + $name = 'name3373707'; + $request = (new DeleteOperationRequest())->setName($name); + try { + $gapicClient->deleteOperation($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getOperationTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $done = true; + $expectedResponse = new Operation(); + $expectedResponse->setName($name2); + $expectedResponse->setDone($done); + $transport->addResponse($expectedResponse); + // Mock request + $name = 'name3373707'; + $request = (new GetOperationRequest())->setName($name); + $response = $gapicClient->getOperation($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($name, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getOperationExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); + $transport->addResponse(null, $status); + // Mock request + $name = 'name3373707'; + $request = (new GetOperationRequest())->setName($name); + try { + $gapicClient->getOperation($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listOperationsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $operationsElement = new Operation(); + $operations = [$operationsElement]; + $expectedResponse = new ListOperationsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setOperations($operations); + $transport->addResponse($expectedResponse); + // Mock request + $name = 'name3373707'; + $filter = 'filter-1274492040'; + $request = (new ListOperationsRequest())->setName($name)->setFilter($filter); + $response = $gapicClient->listOperations($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getOperations()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/ListOperations', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($name, $actualValue); + $actualValue = $actualRequestObject->getFilter(); + $this->assertProtobufEquals($filter, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listOperationsExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); + $transport->addResponse(null, $status); + // Mock request + $name = 'name3373707'; + $filter = 'filter-1274492040'; + $request = (new ListOperationsRequest())->setName($name)->setFilter($filter); + try { + $gapicClient->listOperations($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + /** @test */ public function getLocationTest() {