Skip to content
This repository was archived by the owner on Feb 1, 2024. It is now read-only.

Commit 2e1c777

Browse files
SKAUL05gguuss
authored andcommitted
Adds Task name while creating Task [(#2543)](GoogleCloudPlatform/python-docs-samples#2543)
1 parent 3a44474 commit 2e1c777

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

samples/snippets/create_http_task.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ def create_http_task(project,
2323
location,
2424
url,
2525
payload=None,
26-
in_seconds=None):
26+
in_seconds=None,
27+
task_name=None):
2728
# [START cloud_tasks_create_http_task]
2829
"""Create a task for a given queue with an arbitrary payload."""
2930

@@ -68,6 +69,10 @@ def create_http_task(project,
6869
# Add the timestamp to the tasks.
6970
task['schedule_time'] = timestamp
7071

72+
if task_name is not None:
73+
# Add the name to tasks.
74+
task['name'] = task_name
75+
7176
# Use the client to build and send the task.
7277
response = client.create_task(parent, task)
7378

@@ -115,8 +120,12 @@ def create_http_task(project,
115120
help='The number of seconds from now to schedule task attempt.'
116121
)
117122

123+
parser.add_argument(
124+
'--task_name',
125+
help='Task name of the task to create'
126+
)
118127
args = parser.parse_args()
119128

120129
create_http_task(
121130
args.project, args.queue, args.location, args.url,
122-
args.payload, args.in_seconds)
131+
args.payload, args.in_seconds, args.task_name)

0 commit comments

Comments
 (0)