Complete the code to create a Cloud Tasks client.
from google.cloud import tasks_v2 client = tasks_v2.CloudTasksClient([1])
The CloudTasksClient constructor accepts client_options as an optional argument. Passing None means default options are used.
Complete the code to build the fully qualified queue path.
parent = client.queue_path('[1]', 'us-central1', 'my-queue')
The queue_path method requires the project ID as the first argument.
Fix the error in the task creation code by completing the blank.
task = {
'http_request': {
'http_method': tasks_v2.HttpMethod.POST,
'url': '[1]',
'headers': {'Content-Type': 'application/json'},
'body': b'{"message": "Hello"}'
}
}The URL must be a valid HTTPS URL starting with https:// for Cloud Tasks HTTP requests.
Fill both blanks to schedule a task with a delay of 60 seconds.
import datetime schedule_time = datetime.datetime.utcnow() + datetime.timedelta(seconds=[1]) task['schedule_time'] = schedule_time.[2]()
To schedule a task, add 60 seconds delay and convert to a timestamp using timestamp().
Fill all three blanks to create and send a task to the queue.
response = client.[1]( parent=[2], task=[3] )
The method to send a task is create_task, with parameters parent and task.
