From b47ac01ea236ba21b79abb3e849daaceeb335ad5 Mon Sep 17 00:00:00 2001 From: Sarath Kaul Date: Sat, 16 Nov 2019 14:33:39 +0530 Subject: [PATCH] Added Task name while creating Task --- tasks/create_http_task.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tasks/create_http_task.py b/tasks/create_http_task.py index eb1a446fc9d8..22093edf5470 100644 --- a/tasks/create_http_task.py +++ b/tasks/create_http_task.py @@ -23,7 +23,8 @@ def create_http_task(project, location, url, payload=None, - in_seconds=None): + in_seconds=None, + task_name=None): # [START cloud_tasks_create_http_task] """Create a task for a given queue with an arbitrary payload.""" @@ -68,6 +69,10 @@ def create_http_task(project, # 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(parent, task) @@ -115,8 +120,12 @@ def create_http_task(project, help='The number of seconds from now to schedule task attempt.' ) + parser.add_argument( + '--task_name', + help='Task name of the task to create' + ) args = parser.parse_args() create_http_task( args.project, args.queue, args.location, args.url, - args.payload, args.in_seconds) + args.payload, args.in_seconds, args.task_name)