From 68501442ff9b8b60ef53fa8a31c108306ca9eb0c Mon Sep 17 00:00:00 2001 From: averikitsch Date: Mon, 21 Dec 2020 10:08:44 -0800 Subject: [PATCH 1/2] fix: Update sample comments --- samples/snippets/create_http_task.py | 2 ++ samples/snippets/create_http_task_with_token.py | 17 ----------------- 2 files changed, 2 insertions(+), 17 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..61fcdb07 100644 --- a/samples/snippets/create_http_task_with_token.py +++ b/samples/snippets/create_http_task_with_token.py @@ -24,8 +24,6 @@ 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.""" @@ -63,21 +61,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}) From 92f6201ef568776c57f534145451832eaa9930b9 Mon Sep 17 00:00:00 2001 From: averikitsch Date: Mon, 21 Dec 2020 10:15:40 -0800 Subject: [PATCH 2/2] fix: remove unused imports --- samples/snippets/create_http_task_with_token.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/samples/snippets/create_http_task_with_token.py b/samples/snippets/create_http_task_with_token.py index 61fcdb07..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, @@ -29,7 +27,6 @@ def create_http_task( """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()