27
27
def create_task (project , queue , location ):
28
28
"""Create a task for a given queue with an arbitrary payload."""
29
29
30
+ import googleapiclient .discovery
31
+
30
32
# Create a client.
31
- from googleapiclient import discovery
32
- client = discovery .build (
33
- 'cloudtasks' , 'v2beta2' )
33
+ client = googleapiclient .discovery .build ('cloudtasks' , 'v2beta2' )
34
34
35
35
payload = 'a message for the recipient'
36
36
task = {
@@ -54,10 +54,10 @@ def create_task(project, queue, location):
54
54
def pull_task (project , queue , location ):
55
55
"""Pull a single task from a given queue and lease it for 10 minutes."""
56
56
57
+ import googleapiclient .discovery
58
+
57
59
# Create a client.
58
- from googleapiclient import discovery
59
- client = discovery .build (
60
- 'cloudtasks' , 'v2beta2' )
60
+ client = googleapiclient .discovery .build ('cloudtasks' , 'v2beta2' )
61
61
62
62
duration_seconds = '600s'
63
63
pull_options = {
@@ -79,10 +79,10 @@ def pull_task(project, queue, location):
79
79
def acknowledge_task (task ):
80
80
"""Acknowledge a given task."""
81
81
82
+ import googleapiclient .discovery
83
+
82
84
# Create a client.
83
- from googleapiclient import discovery
84
- client = discovery .build (
85
- 'cloudtasks' , 'v2beta2' )
85
+ client = googleapiclient .discovery .build ('cloudtasks' , 'v2beta2' )
86
86
87
87
body = {'scheduleTime' : task ['scheduleTime' ]}
88
88
client .projects ().locations ().queues ().tasks ().acknowledge (
0 commit comments