8000 Use full import to get client · johnmanong/python-docs-samples@aa6c226 · GitHub
[go: up one dir, main page]

Skip to content

Commit aa6c226

Browse files
committed
Use full import to get client
1 parent 3944287 commit aa6c226

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

appengine/flexible/tasks/create_app_engine_queue_task.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,10 @@ def seconds_from_now_to_rfc3339_datetime(seconds):
2929
def create_task(project, queue, location, payload=None, in_seconds=None):
3030
"""Create a task for a given queue with an arbitrary payload."""
3131

32-
from googleapiclient import discovery
32+
import googleapiclient.discovery
3333

3434
# Create a client.
35-
client = discovery.build(
36-
'cloudtasks', 'v2beta2')
35+
client = googleapiclient.discovery.build('cloudtasks', 'v2beta2')
3736

3837
url = '/log_payload'
3938
body = {

tasks/pull_queue_snippets.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
def create_task(project, queue, location):
2828
"""Create a task for a given queue with an arbitrary payload."""
2929

30+
import googleapiclient.discovery
31+
3032
# Create a client.
31-
from googleapiclient import discovery
32-
client = discovery.build(
33-
'cloudtasks', 'v2beta2')
33+
client = googleapiclient.discovery.build('cloudtasks', 'v2beta2')
3434

3535
payload = 'a message for the recipient'
3636
task = {
@@ -54,10 +54,10 @@ def create_task(project, queue, location):
5454
def pull_task(project, queue, location):
5555
"""Pull a single task from a given queue and lease it for 10 minutes."""
5656

57+
import googleapiclient.discovery
58+
5759
# Create a client.
58-
from googleapiclient import discovery
59-
client = discovery.build(
60-
'cloudtasks', 'v2beta2')
60+
client = googleapiclient.discovery.build('cloudtasks', 'v2beta2')
6161

6262
duration_seconds = '600s'
6363
pull_options = {
@@ -79,10 +79,10 @@ def pull_task(project, queue, location):
7979
def acknowledge_task(task):
8080
"""Acknowledge a given task."""
8181

82+
import googleapiclient.discovery
83+
8284
# Create a client.
83-
from googleapiclient import discovery
84-
client = discovery.build(
85-
'cloudtasks', 'v2beta2')
85+
client = googleapiclient.discovery.build('cloudtasks', 'v2beta2')
8686

8787
body = {'scheduleTime': task['scheduleTime']}
8888
client.projects().locations().queues().tasks().acknowledge(

0 commit comments

Comments
 (0)
0