From 3eb30b349b9092a2a2fb08116855139418ebd371 Mon Sep 17 00:00:00 2001 From: Averi Kitsch Date: Mon, 21 Dec 2020 16:21:46 -0800 Subject: [PATCH] fix: Update sample comments (#58) * fix: Update sample comments * fix: remove unused imports --- samples/snippets/create_http_task.py | 2 ++ .../snippets/create_http_task_with_token.py | 20 ------------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/samples/snippets/create_http_task.py b/samples/snippets/create_http_task.py index 1b75e69c..056dde0c 100644 --- a/samples/snippets/create_http_task.py +++ b/samples/snippets/create_http_task.py @@ -37,6 +37,8 @@ def create_http_task( # location = 'us-central1' # url = 'https://example.com/task_handler' # payload = 'hello' or {'param': 'value'} for application/json + # in_seconds = 180 + # task_name = 'my-unique-task' # Construct the fully qualified queue name. parent = client.queue_path(project, location, queue) diff --git a/samples/snippets/create_http_task_with_token.py b/samples/snippets/create_http_task_with_token.py index 9c32c596..6f690986 100644 --- a/samples/snippets/create_http_task_with_token.py +++ b/samples/snippets/create_http_task_with_token.py @@ -14,8 +14,6 @@ from __future__ import print_function -import datetime - def create_http_task( project, @@ -24,14 +22,11 @@ def create_http_task( url, service_account_email, payload=None, - in_seconds=None, - task_name=None, ): # [START cloud_tasks_create_http_task_with_token] """Create a task for a given queue with an arbitrary payload.""" from google.cloud import tasks_v2 - from google.protobuf import timestamp_pb2 # Create a client. client = tasks_v2.CloudTasksClient() @@ -63,21 +58,6 @@ def create_http_task( # Add the payload to the request. task["http_request"]["body"] = converted_payload - if in_seconds is not None: - # Convert "seconds from now" into an rfc3339 datetime string. - d = datetime.datetime.utcnow() + datetime.timedelta(seconds=in_seconds) - - # Create Timestamp protobuf. - timestamp = timestamp_pb2.Timestamp() - timestamp.FromDatetime(d) - - # Add the timestamp to the tasks. - task["schedule_time"] = timestamp - - if task_name is not None: - # Add the name to tasks. - task["name"] = task_name - # Use the client to build and send the task. response = client.create_task(request={"parent": parent, "task": task})