Skip to content

Commit 9b60124

Browse files
committed
Converting None page tokens into the GAX INITIAL_PAGE.
Introduced in googleapis#2124. Fixes googleapis#2140.
1 parent 302cc70 commit 9b60124

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

gcloud/logging/_gax.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __init__(self, gax_api):
4444
self._gax_api = gax_api
4545

4646
def list_entries(self, projects, filter_='', order_by='',
47-
page_size=0, page_token=INITIAL_PAGE):
47+
page_size=0, page_token=None):
4848
"""Return a page of log entry resources.
4949
5050
:type projects: list of strings
@@ -73,6 +73,8 @@ def list_entries(self, projects, filter_='', order_by='',
7373
if not None, indicates that more entries can be retrieved
7474
with another call (pass that value as ``page_token``).
7575
"""
76+
if page_token is None:
77+
page_token = INITIAL_PAGE
7678
options = CallOptions(page_token=page_token)
7779
page_iter = self._gax_api.list_log_entries(
7880
projects, filter_, order_by, page_size, options)
@@ -135,7 +137,7 @@ class _SinksAPI(object):
135137
def __init__(self, gax_api):
136138
self._gax_api = gax_api
137139

138-
def list_sinks(self, project, page_size=0, page_token=INITIAL_PAGE):
140+
def list_sinks(self, project, page_size=0, page_token=None):
139141
"""List sinks for the project associated with this client.
140142
141143
:type project: string
@@ -155,6 +157,8 @@ def list_sinks(self, project, page_size=0, page_token=INITIAL_PAGE):
155157
if not None, indicates that more sinks can be retrieved
156158
with another call (pass that value as ``page_token``).
157159
"""
160+
if page_token is None:
161+
page_token = INITIAL_PAGE
158162
options = CallOptions(page_token=page_token)
159163
path = 'projects/%s' % (project,)
160164
page_iter = self._gax_api.list_sinks(path, page_size, options)
@@ -279,7 +283,7 @@ class _MetricsAPI(object):
279283
def __init__(self, gax_api):
280284
self._gax_api = gax_api
281285

282-
def list_metrics(self, project, page_size=0, page_token=INITIAL_PAGE):
286+
def list_metrics(self, project, page_size=0, page_token=None):
283287
"""List metrics for the project associated with this client.
284288
285289
:type project: string
@@ -299,6 +303,8 @@ def list_metrics(self, project, page_size=0, page_token=INITIAL_PAGE):
299303
if not None, indicates that more metrics can be retrieved
300304
with another call (pass that value as ``page_token``).
301305
"""
306+
if page_token is None:
307+
page_token = INITIAL_PAGE
302308
options = CallOptions(page_token=page_token)
303309
path = 'projects/%s' % (project,)
304310
page_iter = self._gax_api.list_log_metrics(path, page_size, options)

gcloud/pubsub/_gax.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class _PublisherAPI(object):
3636
def __init__(self, gax_api):
3737
self._gax_api = gax_api
3838

39-
def list_topics(self, project, page_size=0, page_token=INITIAL_PAGE):
39+
def list_topics(self, project, page_size=0, page_token=None):
4040
"""List topics for the project associated with this API.
4141
4242
See:
@@ -60,6 +60,8 @@ def list_topics(self, project, page_size=0, page_token=INITIAL_PAGE):
6060
more topics can be retrieved with another call (pass that
6161
value as ``page_token``).
6262
"""
63+
if page_token is None:
64+
page_token = INITIAL_PAGE
6365
options = CallOptions(page_token=page_token)
6466
path = 'projects/%s' % (project,)
6567
page_iter = self._gax_api.list_topics(
@@ -162,7 +164,7 @@ def topic_publish(self, topic_path, messages):
162164
return result.message_ids
163165

164166
def topic_list_subscriptions(self, topic_path, page_size=0,
165-
page_token=INITIAL_PAGE):
167+
page_token=None):
166168
"""API call: list subscriptions bound to a topic
167169
168170
See:
@@ -187,6 +189,8 @@ def topic_list_subscriptions(self, topic_path, page_size=0,
187189
:raises: :exc:`gcloud.exceptions.NotFound` if the topic does not
188190
exist
189191
"""
192+
if page_token is None:
193+
page_token = INITIAL_PAGE
190194
options = CallOptions(page_token=page_token)
191195
try:
192196
page_iter = self._gax_api.list_topic_subscriptions(
@@ -209,8 +213,7 @@ class _SubscriberAPI(object):
209213
def __init__(self, gax_api):
210214
self._gax_api = gax_api
211215

212-
def list_subscriptions(self, project, page_size=0,
213-
page_token=INITIAL_PAGE):
216+
def list_subscriptions(self, project, page_size=0, page_token=None):
214217
"""List subscriptions for the project associated with this API.
215218
216219
See:
@@ -234,6 +237,8 @@ def list_subscriptions(self, project, page_size=0,
234237
more topics can be retrieved with another call (pass that
235238
value as ``page_token``).
236239
"""
240+
if page_token is None:
241+
page_token = INITIAL_PAGE
237242
options = CallOptions(page_token=page_token)
238243
path = 'projects/%s' % (project,)
239244
page_iter = self._gax_api.list_subscriptions(

0 commit comments

Comments
 (0)