Skip to content

Commit 732e304

Browse files
committed
Passing Client through to low-level logging API objects.
1 parent e054651 commit 732e304

3 files changed

Lines changed: 24 additions & 14 deletions

File tree

packages/google-cloud-logging/google/cloud/logging/_gax.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,13 @@ class _SinksAPI(object):
144144
:type gax_api:
145145
:class:`google.logging.v2.config_service_v2_api.ConfigServiceV2Api`
146146
:param gax_api: API object used to make GAX requests.
147+
148+
:type client: :class:`~google.cloud.logging.client.Client`
149+
:param client: The client that owns this API object.
147150
"""
148-
def __init__(self, gax_api):
151+
def __init__(self, gax_api, client):
149152
self._gax_api = gax_api
153+
self._client = client
150154

151155
def list_sinks(self, project, page_size=0, page_token=None):
152156
"""List sinks for the project associated with this client.
@@ -291,9 +295,13 @@ class _MetricsAPI(object):
291295
:type gax_api:
292296
:class:`google.logging.v2.metrics_service_v2_api.MetricsServiceV2Api`
293297
:param gax_api: API object used to make GAX requests.
298+
299+
:type client: :class:`~google.cloud.logging.client.Client`
300+
:param client: The client that owns this API object.
294301
"""
295-
def __init__(self, gax_api):
302+
def __init__(self, gax_api, client):
296303
self._gax_api = gax_api
304+
self._client = client
297305

298306
def list_metrics(self, project, page_size=0, page_token=None):
299307
"""List metrics for the project associated with this client.

packages/google-cloud-logging/google/cloud/logging/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ def sinks_api(self):
113113
if self._sinks_api is None:
114114
if _USE_GAX:
115115
generated = GeneratedSinksAPI()
116-
self._sinks_api = GAXSinksAPI(generated)
116+
self._sinks_api = GAXSinksAPI(generated, self)
117117
else:
118-
self._sinks_api = JSONSinksAPI(self.connection)
118+
self._sinks_api = JSONSinksAPI(self)
119119
return self._sinks_api
120120

121121
@property
@@ -128,9 +128,9 @@ def metrics_api(self):
128128
if self._metrics_api is None:
129129
if _USE_GAX:
130130
generated = GeneratedMetricsAPI()
131-
self._metrics_api = GAXMetricsAPI(generated)
131+
self._metrics_api = GAXMetricsAPI(generated, self)
132132
else:
133-
self._metrics_api = JSONMetricsAPI(self.connection)
133+
self._metrics_api = JSONMetricsAPI(self)
134134
return self._metrics_api
135135

136136
def logger(self, name):

packages/google-cloud-logging/google/cloud/logging/connection.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,12 @@ class _SinksAPI(object):
184184
See:
185185
https://cloud.google.com/logging/docs/api/reference/rest/v2/projects.sinks
186186
187-
:type connection: :class:`google.cloud.logging.connection.Connection`
188-
:param connection: the connection used to make API requests.
187+
:type client: :class:`~google.cloud.logging.client.Client`
188+
:param client: The client used to make API requests.
189189
"""
190-
def __init__(self, connection):
191-
self._connection = connection
190+
def __init__(self, client):
191+
self._client = client
192+
self._connection = client.connection
192193

193194
def list_sinks(self, project, page_size=None, page_token=None):
194195
"""List sinks for the project associated with this client.
@@ -323,11 +324,12 @@ class _MetricsAPI(object):
323324
See:
324325
https://cloud.google.com/logging/docs/api/reference/rest/v2/projects.metrics
325326
326-
:type connection: :class:`google.cloud.logging.connection.Connection`
327-
:param connection: the connection used to make API requests.
327+
:type client: :class:`~google.cloud.logging.client.Client`
328+
:param client: The client used to make API requests.
328329
"""
329-
def __init__(self, connection):
330-
self._connection = connection
330+
def __init__(self, client):
331+
self._client = client
332+
self._connection = client.connection
331333

332334
def list_metrics(self, project, page_size=None, page_token=None):
333335
"""List metrics for the project associated with this client.

0 commit comments

Comments
 (0)