From 6ab845b9f329b014a31bc439b444a4ec797bf79b Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 18 Jan 2024 19:29:23 +0530 Subject: [PATCH] fix: remove BufferTask method which cannot be called from client libraries (#6971) * fix: remove BufferTask method which cannot be called from client libraries PiperOrigin-RevId: 599211253 Source-Link: https://github.com/googleapis/googleapis/commit/1654062e8ac5d9bcddc4792bc85f4193f8d73cb2 Source-Link: https://github.com/googleapis/googleapis-gen/commit/2055a533af154dcc263d5c0bcd78af84b44ef332 Copy-Tag: eyJwIjoiVGFza3MvLk93bEJvdC55YW1sIiwiaCI6IjIwNTVhNTMzYWYxNTRkY2MyNjNkNWMwYmNkNzhhZjg0YjQ0ZWYzMzIifQ== --- Tasks/metadata/V2Beta2/Cloudtasks.php | Bin 8966 -> 8540 bytes Tasks/metadata/V2Beta3/Cloudtasks.php | 17 +--- .../V2beta2/Gapic/CloudTasksGapicClient.php | 73 ---------------- Tasks/src/V2beta2/gapic_metadata.json | 5 -- .../resources/cloud_tasks_client_config.json | 5 -- .../cloud_tasks_rest_client_config.php | 17 ---- .../V2beta3/Gapic/CloudTasksGapicClient.php | 79 +----------------- Tasks/src/V2beta3/gapic_metadata.json | 5 -- .../resources/cloud_tasks_client_config.json | 5 -- .../cloud_tasks_rest_client_config.php | 17 ---- .../Unit/V2beta2/CloudTasksClientTest.php | 59 ------------- .../Unit/V2beta3/CloudTasksClientTest.php | 59 ------------- 12 files changed, 7 insertions(+), 334 deletions(-) diff --git a/Tasks/metadata/V2Beta2/Cloudtasks.php b/Tasks/metadata/V2Beta2/Cloudtasks.php index 69849c057f9c76b903fe27ffaef2b4843e1c502f..0ee8065355d64963cfa3f15bb57910272fb211f1 100644 GIT binary patch delta 45 zcmZp3yW_OsHVexp3oh-+2Uw*y|6=LnVK&+-yE#%QjgM8z_mrdLWCb3{&07?M7y*Ag B4>AA% delta 305 zcmccP)aJI~HVeybYcB1{2Uw*y|6=Lnkyq+u=%wf9r{|>V zB^G4rd6bkCI05CrDwSNggph40F38U-P8HJQVgZ>d!3fr_FgZ|2X0m|*3$sy={N^^n zG(K*jD~w!R5RH=?rInyekSiy9%cyE$8mW}tbot3-CLbkt{W7DZ)RIIa{c4aeCJTxv nO^%ml)6}nq`lHq=3G8JnMy*?pLSUcjK&5m*e%ky-zJL(`#lK=B diff --git a/Tasks/metadata/V2Beta3/Cloudtasks.php b/Tasks/metadata/V2Beta3/Cloudtasks.php index a3891756f310..c492fe303df0 100644 --- a/Tasks/metadata/V2Beta3/Cloudtasks.php +++ b/Tasks/metadata/V2Beta3/Cloudtasks.php @@ -17,7 +17,6 @@ public static function initOnce() { \GPBMetadata\Google\Api\Annotations::initOnce(); \GPBMetadata\Google\Api\Client::initOnce(); \GPBMetadata\Google\Api\FieldBehavior::initOnce(); - \GPBMetadata\Google\Api\Httpbody::initOnce(); \GPBMetadata\Google\Api\Resource::initOnce(); \GPBMetadata\Google\Cloud\Tasks\V2Beta3\Queue::initOnce(); \GPBMetadata\Google\Cloud\Tasks\V2Beta3\Task::initOnce(); @@ -27,8 +26,8 @@ public static function initOnce() { \GPBMetadata\Google\Protobuf\FieldMask::initOnce(); $pool->internalAddGeneratedFile( ' -Û+ -+google/cloud/tasks/v2beta3/cloudtasks.protogoogle.cloud.tasks.v2beta3google/api/client.protogoogle/api/field_behavior.protogoogle/api/httpbody.protogoogle/api/resource.proto&google/cloud/tasks/v2beta3/queue.proto%google/cloud/tasks/v2beta3/task.protogoogle/iam/v1/iam_policy.protogoogle/iam/v1/policy.protogoogle/protobuf/empty.proto google/protobuf/field_mask.proto"· +—( ++google/cloud/tasks/v2beta3/cloudtasks.protogoogle.cloud.tasks.v2beta3google/api/client.protogoogle/api/field_behavior.protogoogle/api/resource.proto&google/cloud/tasks/v2beta3/queue.proto%google/cloud/tasks/v2beta3/task.protogoogle/iam/v1/iam_policy.protogoogle/iam/v1/policy.protogoogle/protobuf/empty.proto google/protobuf/field_mask.proto"· ListQueuesRequest7 parent ( B\'àAúA!cloudtasks.googleapis.com/Queue filter (  @@ -84,13 +83,7 @@ public static function initOnce() { RunTaskRequest4 name ( B&àAúA cloudtasks.googleapis.com/Task< - response_view (2%.google.cloud.tasks.v2beta3.Task.View"‰ -BufferTaskRequest5 -queue ( B&àAúA cloudtasks.googleapis.com/Task -task_id ( BàA\' -body ( 2.google.api.HttpBodyBàA"D -BufferTaskResponse. -task ( 2 .google.cloud.tasks.v2beta3.Task2ü + response_view (2%.google.cloud.tasks.v2beta3.Task.View2¥ CloudTasks­ @@ -113,9 +106,7 @@ public static function initOnce() { CreateTask-.google.cloud.tasks.v2beta3.CreateTaskRequest .google.cloud.tasks.v2beta3.Task"P‚Óä“<"7/v2beta3/{parent=projects/*/locations/*/queues/*}/tasks:*ÚA parent,task› DeleteTask-.google.cloud.tasks.v2beta3.DeleteTaskRequest.google.protobuf.Empty"F‚Óä“9*7/v2beta3/{name=projects/*/locations/*/queues/*/tasks/*}ÚAname¦ -RunTask*.google.cloud.tasks.v2beta3.RunTaskRequest .google.cloud.tasks.v2beta3.Task"M‚Óä“@";/v2beta3/{name=projects/*/locations/*/queues/*/tasks/*}:run:*ÚAnameÔ - -BufferTask-.google.cloud.tasks.v2beta3.BufferTaskRequest..google.cloud.tasks.v2beta3.BufferTaskResponse"g‚Óä“L"G/v2beta3/{queue=projects/*/locations/*/queues/*}/tasks/{task_id}:buffer:*ÚAqueue,task_id,bodyMÊAcloudtasks.googleapis.comÒA.https://www.googleapis.com/auth/cloud-platformB€ +RunTask*.google.cloud.tasks.v2beta3.RunTaskRequest .google.cloud.tasks.v2beta3.Task"M‚Óä“@";/v2beta3/{name=projects/*/locations/*/queues/*/tasks/*}:run:*ÚAnameMÊAcloudtasks.googleapis.comÒA.https://www.googleapis.com/auth/cloud-platformB€ com.google.cloud.tasks.v2beta3BCloudTasksProtoPZCcloud.google.com/go/cloudtasks/apiv2beta3/cloudtaskspb;cloudtaskspb¢TASKSbproto3' , true); diff --git a/Tasks/src/V2beta2/Gapic/CloudTasksGapicClient.php b/Tasks/src/V2beta2/Gapic/CloudTasksGapicClient.php index 8bd8e07d3209..b6604453f65a 100644 --- a/Tasks/src/V2beta2/Gapic/CloudTasksGapicClient.php +++ b/Tasks/src/V2beta2/Gapic/CloudTasksGapicClient.php @@ -48,8 +48,6 @@ use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; use Google\Cloud\Tasks\V2beta2\AcknowledgeTaskRequest; -use Google\Cloud\Tasks\V2beta2\BufferTaskRequest; -use Google\Cloud\Tasks\V2beta2\BufferTaskResponse; use Google\Cloud\Tasks\V2beta2\CancelLeaseRequest; use Google\Cloud\Tasks\V2beta2\CreateQueueRequest; use Google\Cloud\Tasks\V2beta2\CreateTaskRequest; @@ -456,77 +454,6 @@ public function acknowledgeTask($name, $scheduleTime, array $optionalArgs = []) return $this->startCall('AcknowledgeTask', GPBEmpty::class, $optionalArgs, $request)->wait(); } - /** - * Creates and buffers a new task without the need to explicitly define a Task - * message. The queue must have [HTTP - * target][google.cloud.tasks.v2beta2.HttpTarget]. To create the task with a - * custom ID, use the following format and set TASK_ID to your desired ID: - * projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID:buffer - * To create the task with an automatically generated ID, use the following - * format: - * projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks:buffer. - * Note: This feature is in its experimental stage. You must request access to - * the API through the [Cloud Tasks BufferTask Experiment Signup - * form](https://forms.gle/X8Zr5hiXH5tTGFqh8). - * - * Sample code: - * ``` - * $cloudTasksClient = new CloudTasksClient(); - * try { - * $formattedQueue = $cloudTasksClient->queueName('[PROJECT]', '[LOCATION]', '[QUEUE]'); - * $response = $cloudTasksClient->bufferTask($formattedQueue); - * } finally { - * $cloudTasksClient->close(); - * } - * ``` - * - * @param string $queue Required. The parent queue name. For example: - * projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` - * - * The queue must already exist. - * @param array $optionalArgs { - * Optional. - * - * @type string $taskId - * Optional. Task ID for the task being created. If not provided, a random - * task ID is assigned to the task. - * @type HttpBody $body - * Optional. Body of the HTTP request. - * - * The body can take any generic value. The value is written to the - * [HttpRequest][payload] of the [Task]. - * @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 \Google\Cloud\Tasks\V2beta2\BufferTaskResponse - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function bufferTask($queue, array $optionalArgs = []) - { - $request = new BufferTaskRequest(); - $requestParamHeaders = []; - $request->setQueue($queue); - $requestParamHeaders['queue'] = $queue; - if (isset($optionalArgs['taskId'])) { - $request->setTaskId($optionalArgs['taskId']); - $requestParamHeaders['task_id'] = $optionalArgs['taskId']; - } - - if (isset($optionalArgs['body'])) { - $request->setBody($optionalArgs['body']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('BufferTask', BufferTaskResponse::class, $optionalArgs, $request)->wait(); - } - /** * Cancel a pull task's lease. * diff --git a/Tasks/src/V2beta2/gapic_metadata.json b/Tasks/src/V2beta2/gapic_metadata.json index 4f138f7d661e..92458443760a 100644 --- a/Tasks/src/V2beta2/gapic_metadata.json +++ b/Tasks/src/V2beta2/gapic_metadata.json @@ -15,11 +15,6 @@ "acknowledgeTask" ] }, - "BufferTask": { - "methods": [ - "bufferTask" - ] - }, "CancelLease": { "methods": [ "cancelLease" diff --git a/Tasks/src/V2beta2/resources/cloud_tasks_client_config.json b/Tasks/src/V2beta2/resources/cloud_tasks_client_config.json index 474578c40fe2..3e49652fe97e 100644 --- a/Tasks/src/V2beta2/resources/cloud_tasks_client_config.json +++ b/Tasks/src/V2beta2/resources/cloud_tasks_client_config.json @@ -44,11 +44,6 @@ "retry_codes_name": "no_retry_1_codes", "retry_params_name": "no_retry_1_params" }, - "BufferTask": { - "timeout_millis": 20000, - "retry_codes_name": "no_retry_1_codes", - "retry_params_name": "no_retry_1_params" - }, "CancelLease": { "timeout_millis": 20000, "retry_codes_name": "no_retry_1_codes", diff --git a/Tasks/src/V2beta2/resources/cloud_tasks_rest_client_config.php b/Tasks/src/V2beta2/resources/cloud_tasks_rest_client_config.php index fb91babcb5ee..d6a4e451cb37 100644 --- a/Tasks/src/V2beta2/resources/cloud_tasks_rest_client_config.php +++ b/Tasks/src/V2beta2/resources/cloud_tasks_rest_client_config.php @@ -39,23 +39,6 @@ ], ], ], - 'BufferTask' => [ - 'method' => 'post', - 'uriTemplate' => '/v2beta2/{queue=projects/*/locations/*/queues/*}/tasks/{task_id}:buffer', - 'body' => '*', - 'placeholders' => [ - 'queue' => [ - 'getters' => [ - 'getQueue', - ], - ], - 'task_id' => [ - 'getters' => [ - 'getTaskId', - ], - ], - ], - ], 'CancelLease' => [ 'method' => 'post', 'uriTemplate' => '/v2beta2/{name=projects/*/locations/*/queues/*/tasks/*}:cancelLease', diff --git a/Tasks/src/V2beta3/Gapic/CloudTasksGapicClient.php b/Tasks/src/V2beta3/Gapic/CloudTasksGapicClient.php index 226795b38eb4..25ce83312745 100644 --- a/Tasks/src/V2beta3/Gapic/CloudTasksGapicClient.php +++ b/Tasks/src/V2beta3/Gapic/CloudTasksGapicClient.php @@ -35,7 +35,6 @@ use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; use Google\ApiCore\ValidationException; -use Google\Api\HttpBody; use Google\Auth\FetchAuthTokenInterface; use Google\Cloud\Iam\V1\GetIamPolicyRequest; use Google\Cloud\Iam\V1\GetPolicyOptions; @@ -47,8 +46,6 @@ use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; -use Google\Cloud\Tasks\V2beta3\BufferTaskRequest; -use Google\Cloud\Tasks\V2beta3\BufferTaskResponse; use Google\Cloud\Tasks\V2beta3\CreateQueueRequest; use Google\Cloud\Tasks\V2beta3\CreateTaskRequest; use Google\Cloud\Tasks\V2beta3\DeleteQueueRequest; @@ -80,8 +77,9 @@ * ``` * $cloudTasksClient = new CloudTasksClient(); * try { - * $formattedQueue = $cloudTasksClient->queueName('[PROJECT]', '[LOCATION]', '[QUEUE]'); - * $response = $cloudTasksClient->bufferTask($formattedQueue); + * $formattedParent = $cloudTasksClient->locationName('[PROJECT]', '[LOCATION]'); + * $queue = new Queue(); + * $response = $cloudTasksClient->createQueue($formattedParent, $queue); * } finally { * $cloudTasksClient->close(); * } @@ -387,77 +385,6 @@ public function __construct(array $options = []) $this->setClientOptions($clientOptions); } - /** - * Creates and buffers a new task without the need to explicitly define a Task - * message. The queue must have [HTTP - * target][google.cloud.tasks.v2beta3.HttpTarget]. To create the task with a - * custom ID, use the following format and set TASK_ID to your desired ID: - * projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID:buffer - * To create the task with an automatically generated ID, use the following - * format: - * projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks:buffer. - * Note: This feature is in its experimental stage. You must request access to - * the API through the [Cloud Tasks BufferTask Experiment Signup - * form](https://forms.gle/X8Zr5hiXH5tTGFqh8). - * - * Sample code: - * ``` - * $cloudTasksClient = new CloudTasksClient(); - * try { - * $formattedQueue = $cloudTasksClient->queueName('[PROJECT]', '[LOCATION]', '[QUEUE]'); - * $response = $cloudTasksClient->bufferTask($formattedQueue); - * } finally { - * $cloudTasksClient->close(); - * } - * ``` - * - * @param string $queue Required. The parent queue name. For example: - * projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` - * - * The queue must already exist. - * @param array $optionalArgs { - * Optional. - * - * @type string $taskId - * Optional. Task ID for the task being created. If not provided, a random - * task ID is assigned to the task. - * @type HttpBody $body - * Optional. Body of the HTTP request. - * - * The body can take any generic value. The value is written to the - * [HttpRequest][payload] of the [Task]. - * @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 \Google\Cloud\Tasks\V2beta3\BufferTaskResponse - * - * @throws ApiException if the remote call fails - * - * @experimental - */ - public function bufferTask($queue, array $optionalArgs = []) - { - $request = new BufferTaskRequest(); - $requestParamHeaders = []; - $request->setQueue($queue); - $requestParamHeaders['queue'] = $queue; - if (isset($optionalArgs['taskId'])) { - $request->setTaskId($optionalArgs['taskId']); - $requestParamHeaders['task_id'] = $optionalArgs['taskId']; - } - - if (isset($optionalArgs['body'])) { - $request->setBody($optionalArgs['body']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('BufferTask', BufferTaskResponse::class, $optionalArgs, $request)->wait(); - } - /** * Creates a queue. * diff --git a/Tasks/src/V2beta3/gapic_metadata.json b/Tasks/src/V2beta3/gapic_metadata.json index 1ca31a8697ef..91fdac01bfc2 100644 --- a/Tasks/src/V2beta3/gapic_metadata.json +++ b/Tasks/src/V2beta3/gapic_metadata.json @@ -10,11 +10,6 @@ "grpc": { "libraryClient": "CloudTasksGapicClient", "rpcs": { - "BufferTask": { - "methods": [ - "bufferTask" - ] - }, "CreateQueue": { "methods": [ "createQueue" diff --git a/Tasks/src/V2beta3/resources/cloud_tasks_client_config.json b/Tasks/src/V2beta3/resources/cloud_tasks_client_config.json index fe35f305c38b..d68dd2e3a24f 100644 --- a/Tasks/src/V2beta3/resources/cloud_tasks_client_config.json +++ b/Tasks/src/V2beta3/resources/cloud_tasks_client_config.json @@ -39,11 +39,6 @@ } }, "methods": { - "BufferTask": { - "timeout_millis": 20000, - "retry_codes_name": "no_retry_1_codes", - "retry_params_name": "no_retry_1_params" - }, "CreateQueue": { "timeout_millis": 20000, "retry_codes_name": "no_retry_1_codes", diff --git a/Tasks/src/V2beta3/resources/cloud_tasks_rest_client_config.php b/Tasks/src/V2beta3/resources/cloud_tasks_rest_client_config.php index 73f0644e4160..8bcffbc8b257 100644 --- a/Tasks/src/V2beta3/resources/cloud_tasks_rest_client_config.php +++ b/Tasks/src/V2beta3/resources/cloud_tasks_rest_client_config.php @@ -27,23 +27,6 @@ ], ], 'google.cloud.tasks.v2beta3.CloudTasks' => [ - 'BufferTask' => [ - 'method' => 'post', - 'uriTemplate' => '/v2beta3/{queue=projects/*/locations/*/queues/*}/tasks/{task_id}:buffer', - 'body' => '*', - 'placeholders' => [ - 'queue' => [ - 'getters' => [ - 'getQueue', - ], - ], - 'task_id' => [ - 'getters' => [ - 'getTaskId', - ], - ], - ], - ], 'CreateQueue' => [ 'method' => 'post', 'uriTemplate' => '/v2beta3/{parent=projects/*/locations/*}/queues', diff --git a/Tasks/tests/Unit/V2beta2/CloudTasksClientTest.php b/Tasks/tests/Unit/V2beta2/CloudTasksClientTest.php index ef6b948f41c3..a35c5a4d9ef9 100644 --- a/Tasks/tests/Unit/V2beta2/CloudTasksClientTest.php +++ b/Tasks/tests/Unit/V2beta2/CloudTasksClientTest.php @@ -30,7 +30,6 @@ use Google\Cloud\Iam\V1\TestIamPermissionsResponse; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; -use Google\Cloud\Tasks\V2beta2\BufferTaskResponse; use Google\Cloud\Tasks\V2beta2\CloudTasksClient; use Google\Cloud\Tasks\V2beta2\LeaseTasksResponse; use Google\Cloud\Tasks\V2beta2\ListQueuesResponse; @@ -132,64 +131,6 @@ public function acknowledgeTaskExceptionTest() $this->assertTrue($transport->isExhausted()); } - /** @test */ - public function bufferTaskTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new BufferTaskResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedQueue = $gapicClient->queueName('[PROJECT]', '[LOCATION]', '[QUEUE]'); - $response = $gapicClient->bufferTask($formattedQueue); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.tasks.v2beta2.CloudTasks/BufferTask', $actualFuncCall); - $actualValue = $actualRequestObject->getQueue(); - $this->assertProtobufEquals($formattedQueue, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function bufferTaskExceptionTest() - { - $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 - $formattedQueue = $gapicClient->queueName('[PROJECT]', '[LOCATION]', '[QUEUE]'); - try { - $gapicClient->bufferTask($formattedQueue); - // 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 cancelLeaseTest() { diff --git a/Tasks/tests/Unit/V2beta3/CloudTasksClientTest.php b/Tasks/tests/Unit/V2beta3/CloudTasksClientTest.php index ecd4f91ad239..2e06c858c79f 100644 --- a/Tasks/tests/Unit/V2beta3/CloudTasksClientTest.php +++ b/Tasks/tests/Unit/V2beta3/CloudTasksClientTest.php @@ -30,7 +30,6 @@ use Google\Cloud\Iam\V1\TestIamPermissionsResponse; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; -use Google\Cloud\Tasks\V2beta3\BufferTaskResponse; use Google\Cloud\Tasks\V2beta3\CloudTasksClient; use Google\Cloud\Tasks\V2beta3\ListQueuesResponse; use Google\Cloud\Tasks\V2beta3\ListTasksResponse; @@ -68,64 +67,6 @@ private function createClient(array $options = []) return new CloudTasksClient($options); } - /** @test */ - public function bufferTaskTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new BufferTaskResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedQueue = $gapicClient->queueName('[PROJECT]', '[LOCATION]', '[QUEUE]'); - $response = $gapicClient->bufferTask($formattedQueue); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.cloud.tasks.v2beta3.CloudTasks/BufferTask', $actualFuncCall); - $actualValue = $actualRequestObject->getQueue(); - $this->assertProtobufEquals($formattedQueue, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function bufferTaskExceptionTest() - { - $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 - $formattedQueue = $gapicClient->queueName('[PROJECT]', '[LOCATION]', '[QUEUE]'); - try { - $gapicClient->bufferTask($formattedQueue); - // 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 createQueueTest() {