File tree 2 files changed +2
-20
lines changed
2 files changed +2
-20
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,8 @@ def create_http_task(
37
37
# location = 'us-central1'
38
38
# url = 'https://example.com/task_handler'
39
39
# payload = 'hello' or {'param': 'value'} for application/json
40
+ # in_seconds = 180
41
+ # task_name = 'my-unique-task'
40
42
41
43
# Construct the fully qualified queue name.
42
44
parent = client .queue_path (project , location , queue )
Original file line number Diff line number Diff line change 14
14
15
15
from __future__ import print_function
16
16
17
- import datetime
18
-
19
17
20
18
def create_http_task (
21
19
project ,
@@ -24,14 +22,11 @@ def create_http_task(
24
22
url ,
25
23
service_account_email ,
26
24
payload = None ,
27
- in_seconds = None ,
28
- task_name = None ,
29
25
):
30
26
# [START cloud_tasks_create_http_task_with_token]
31
27
"""Create a task for a given queue with an arbitrary payload."""
32
28
33
29
from google .cloud import tasks_v2
34
- from google .protobuf import timestamp_pb2
35
30
36
31
# Create a client.
37
32
client = tasks_v2 .CloudTasksClient ()
@@ -63,21 +58,6 @@ def create_http_task(
63
58
# Add the payload to the request.
64
59
task ["http_request" ]["body" ] = converted_payload
65
60
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
-
81
61
# Use the client to build and send the task.
82
62
response = client .create_task (request = {"parent" : parent , "task" : task })
83
63
You can’t perform that action at this time.
0 commit comments