public final Task cancelLease(String name, Timestamp scheduleTime) {
    CancelLeaseRequest request =
        CancelLeaseRequest.newBuilder().setName(name).setScheduleTime(scheduleTime).build();
    return cancelLease(request);
  }
Cancel a pull task's lease.

<p>The worker can use this method to cancel a task's lease by setting its
[schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time] to now. This will make the task
available to be leased to the next caller of
[LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks].

<p>Sample code:

<pre>{@code
// This snippet 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 as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
  String name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]").toString();
  Timestamp scheduleTime = Timestamp.newBuilder().build();
  Task response = cloudTasksClient.cancelLease(name, scheduleTime);
}
}</pre>

@param name Required. The task name. For example:
    `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
@param scheduleTime Required. The task's current schedule time, available in the
    [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time] returned by
    [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks] response or
    [RenewLease][google.cloud.tasks.v2beta2.CloudTasks.RenewLease] response. This restriction
    is to ensure that your worker currently holds the lease.
@throws com.google.api.gax.rpc.ApiException if the remote call fails
java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta2/CloudTasksClient.java