Skip to content

Commit ad9417f

Browse files
committed
Changing monitoring Connection to only accept client.
1 parent 725b4f0 commit ad9417f

4 files changed

Lines changed: 10 additions & 11 deletions

File tree

monitoring/google/cloud/monitoring/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@
4444
)
4545

4646

47-
SCOPE = Connection.SCOPE
47+
SCOPE = Client.SCOPE

monitoring/google/cloud/monitoring/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,15 @@ class Client(ClientWithProject):
6868
``credentials`` for the current object.
6969
"""
7070

71+
SCOPE = ('https://www.googleapis.com/auth/monitoring.read',
72+
'https://www.googleapis.com/auth/monitoring',
73+
'https://www.googleapis.com/auth/cloud-platform')
74+
"""The scopes required for authenticating as a Monitoring consumer."""
75+
7176
def __init__(self, project=None, credentials=None, http=None):
7277
super(Client, self).__init__(
7378
project=project, credentials=credentials, http=http)
74-
self._connection = Connection(
75-
credentials=self._credentials, http=self._http)
79+
self._connection = Connection(self)
7680

7781
def query(self,
7882
metric_type=Query.DEFAULT_METRIC_TYPE,

monitoring/google/cloud/monitoring/connection.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,3 @@ class Connection(_http.JSONConnection):
4040

4141
API_URL_TEMPLATE = '{api_base_url}/{api_version}{path}'
4242
"""A template for the URL of a particular API call."""
43-
44-
SCOPE = ('https://www.googleapis.com/auth/monitoring.read',
45-
'https://www.googleapis.com/auth/monitoring',
46-
'https://www.googleapis.com/auth/cloud-platform')
47-
"""The scopes required for authenticating as a Monitoring consumer."""

monitoring/unit_tests/test_connection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ def _make_one(self, *args, **kwargs):
2727
return self._get_target_class()(*args, **kwargs)
2828

2929
def test_constructor(self):
30-
credentials = object()
31-
connection = self._make_one(credentials)
32-
self.assertEqual(connection.credentials, credentials)
30+
client = object()
31+
connection = self._make_one(client)
32+
self.assertIs(connection._client, client)

0 commit comments

Comments
 (0)