Skip to content

Commit 842b9c4

Browse files
averikitschdandhlee
authored andcommitted
fix: Update sample comments (#58)
* fix: Update sample comments * fix: remove unused imports
1 parent b22a46e commit 842b9c4

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

cloud-tasks/snippets/create_http_task.py

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ def create_http_task(
3737
# location = 'us-central1'
3838
# url = 'https://example.com/task_handler'
3939
# payload = 'hello' or {'param': 'value'} for application/json
40+
# in_seconds = 180
41+
# task_name = 'my-unique-task'
4042

4143
# Construct the fully qualified queue name.
4244
parent = client.queue_path(project, location, queue)

cloud-tasks/snippets/create_http_task_with_token.py

-20
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
from __future__ import print_function
1616

17-
import datetime
18-
1917

2018
def create_http_task(
2119
project,
@@ -24,14 +22,11 @@ def create_http_task(
2422
url,
2523
service_account_email,
2624
payload=None,
27-
in_seconds=None,
28-
task_name=None,
2925
):
3026
# [START cloud_tasks_create_http_task_with_token]
3127
"""Create a task for a given queue with an arbitrary payload."""
3228

3329
from google.cloud import tasks_v2
34-
from google.protobuf import timestamp_pb2
3530

3631
# Create a client.
3732
client = tasks_v2.CloudTasksClient()
@@ -63,21 +58,6 @@ def create_http_task(
6358
# Add the payload to the request.
6459
task["http_request"]["body"] = converted_payload
6560

66-
if in_seconds is not None:
67-
# Convert "seconds from now" into an rfc3339 datetime string.
68-
d = datetime.datetime.utcnow() + datetime.timedelta(seconds=in_seconds)
69-
70-
# Create Timestamp protobuf.
71-
timestamp = timestamp_pb2.Timestamp()
72-
timestamp.FromDatetime(d)
73-
74-
# Add the timestamp to the tasks.
75-
task["schedule_time"] = timestamp
76-
77-
if task_name is not None:
78-
# Add the name to tasks.
79-
task["name"] = task_name
80-
8161
# Use the client to build and send the task.
8262
response = client.create_task(request={"parent": parent, "task": task})
8363

0 commit comments

Comments
 (0)