Skip to content

Commit f651cce

Browse files
committed
Changing logging Connection to only accept client.
1 parent 69d998d commit f651cce

File tree

3 files changed

+12
-21
lines changed

3 files changed

+12
-21
lines changed

logging/google/cloud/logging/_http.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,8 @@
2626
class Connection(_http.JSONConnection):
2727
"""A connection to Google Stackdriver Logging via the JSON REST API.
2828
29-
:type credentials: :class:`oauth2client.client.OAuth2Credentials`
30-
:param credentials: (Optional) The OAuth2 Credentials to use for this
31-
connection.
32-
33-
:type http: :class:`httplib2.Http` or class that defines ``request()``.
34-
:param http: (Optional) HTTP object to make requests.
35-
36-
:type api_base_url: str
37-
:param api_base_url: The base of the API call URL. Defaults to the value
38-
:attr:`Connection.API_BASE_URL`.
29+
:type client: :class:`~google.cloud.logging.client.Client`
30+
:param client: The client that owns the current connection.
3931
"""
4032

4133
API_BASE_URL = 'https://logging.googleapis.com'
@@ -47,12 +39,6 @@ class Connection(_http.JSONConnection):
4739
API_URL_TEMPLATE = '{api_base_url}/{api_version}{path}'
4840
"""A template for the URL of a particular API call."""
4941

50-
SCOPE = ('https://www.googleapis.com/auth/logging.read',
51-
'https://www.googleapis.com/auth/logging.write',
52-
'https://www.googleapis.com/auth/logging.admin',
53-
'https://www.googleapis.com/auth/cloud-platform')
54-
"""The scopes required for authenticating as a Logging consumer."""
55-
5642

5743
class _LoggingAPI(object):
5844
"""Helper mapping logging-related APIs.

logging/google/cloud/logging/client.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,17 @@ class Client(ClientWithProject):
9191
_sinks_api = None
9292
_metrics_api = None
9393

94+
SCOPE = ('https://www.googleapis.com/auth/logging.read',
95+
'https://www.googleapis.com/auth/logging.write',
96+
'https://www.googleapis.com/auth/logging.admin',
97+
'https://www.googleapis.com/auth/cloud-platform')
98+
"""The scopes required for authenticating as a Logging consumer."""
99+
94100
def __init__(self, project=None, credentials=None,
95101
http=None, use_gax=None):
96102
super(Client, self).__init__(
97103
project=project, credentials=credentials, http=http)
98-
self._connection = Connection(
99-
credentials=self._credentials, http=self._http)
104+
self._connection = Connection(self)
100105
if use_gax is None:
101106
self._use_gax = _USE_GAX
102107
else:

logging/unit_tests/test__http.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ def _make_one(self, *args, **kw):
3838
return self._get_target_class()(*args, **kw)
3939

4040
def test_default_url(self):
41-
creds = _make_credentials()
42-
conn = self._make_one(creds)
43-
self.assertEqual(conn.credentials, creds)
41+
client = object()
42+
conn = self._make_one(client)
43+
self.assertIs(conn._client, client)
4444

4545

4646
class Test_LoggingAPI(unittest.TestCase):

0 commit comments

Comments
 (0)