Skip to content

Commit 305ca1b

Browse files
authored
Merge pull request #2970 from dhermes/cnxn-client-hygiene
Making Connection()-s act as proxies for data stored in Client()-s
2 parents 6fcddd7 + 241890e commit 305ca1b

3 files changed

Lines changed: 10 additions & 18 deletions

File tree

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,17 @@ class Client(ClientWithProject):
5555
falls back to the ``GOOGLE_CLOUD_DISABLE_GRPC`` environment
5656
variable
5757
"""
58+
59+
SCOPE = ('https://www.googleapis.com/auth/cloud-platform',)
60+
"""The scopes required for authenticating as a Cloud Vision consumer."""
61+
5862
_vision_api_internal = None
5963

6064
def __init__(self, project=None, credentials=None, http=None,
6165
use_gax=None):
6266
super(Client, self).__init__(
6367
project=project, credentials=credentials, http=http)
64-
self._connection = Connection(
65-
credentials=self._credentials, http=self._http)
68+
self._connection = Connection(self)
6669
if use_gax is None:
6770
self._use_gax = _USE_GAX
6871
else:

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,8 @@
2222
class Connection(_http.JSONConnection):
2323
"""A connection to Google Cloud Vision via the JSON REST API.
2424
25-
:type credentials: :class:`oauth2client.client.OAuth2Credentials`
26-
:param credentials: (Optional) The OAuth2 Credentials to use for this
27-
connection.
28-
29-
:type http: :class:`httplib2.Http` or class that defines ``request()``.
30-
:param http: (Optional) HTTP object to make requests.
31-
32-
:type api_base_url: str
33-
:param api_base_url: The base of the API call URL. Defaults to the value
34-
:attr:`Connection.API_BASE_URL`.
25+
:type client: :class:`~google.cloud.vision.client.Client`
26+
:param client: The client that owns the current connection.
3527
"""
3628

3729
API_BASE_URL = 'https://vision.googleapis.com'
@@ -42,6 +34,3 @@ class Connection(_http.JSONConnection):
4234

4335
API_URL_TEMPLATE = '{api_base_url}/{api_version}{path}'
4436
"""A template for the URL of a particular API call."""
45-
46-
SCOPE = ('https://www.googleapis.com/auth/cloud-platform',)
47-
"""The scopes required for authenticating as a Cloud Vision consumer."""

packages/google-cloud-vision/unit_tests/test_connection.py

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

2828
def test_default_url(self):
29-
creds = object()
30-
conn = self._make_one(creds)
31-
self.assertEqual(conn.credentials, creds)
29+
client = object()
30+
conn = self._make_one(client)
31+
self.assertEqual(conn._client, client)

0 commit comments

Comments
 (0)