Skip to content

Commit 5961058

Browse files
authored
Merge pull request #3033 from dhermes/no-more-connection-modules
Renaming all remaining connection.py modules as _http.py.
2 parents 4026523 + ba10c43 commit 5961058

6 files changed

Lines changed: 38 additions & 69 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
# limitations under the License.
1414

1515
"""Google Cloud Vision API package."""
16+
1617
from google.cloud.vision.client import Client

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,29 @@
1414

1515
"""HTTP Client for interacting with the Google Cloud Vision API."""
1616

17+
from google.cloud import _http
18+
1719
from google.cloud.vision.annotations import Annotations
1820
from google.cloud.vision.feature import Feature
1921

2022

23+
class Connection(_http.JSONConnection):
24+
"""A connection to Google Cloud Vision via the JSON REST API.
25+
26+
:type client: :class:`~google.cloud.vision.client.Client`
27+
:param client: The client that owns the current connection.
28+
"""
29+
30+
API_BASE_URL = 'https://vision.googleapis.com'
31+
"""The base of the API call URL."""
32+
33+
API_VERSION = 'v1'
34+
"""The version of the API, used in building the API call's URL."""
35+
36+
API_URL_TEMPLATE = '{api_base_url}/{api_version}{path}'
37+
"""A template for the URL of a particular API call."""
38+
39+
2140
class _HTTPVisionAPI(object):
2241
"""Vision API for interacting with the JSON/HTTP version of Vision
2342

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
from google.cloud.environment_vars import DISABLE_GRPC
2121

2222
from google.cloud.vision._gax import _GAPICVisionAPI
23+
from google.cloud.vision._http import _HTTPVisionAPI
24+
from google.cloud.vision._http import Connection
2325
from google.cloud.vision.batch import Batch
24-
from google.cloud.vision.connection import Connection
2526
from google.cloud.vision.image import Image
26-
from google.cloud.vision._http import _HTTPVisionAPI
2727

2828

2929
_USE_GAX = not os.getenv(DISABLE_GRPC, False)

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

Lines changed: 0 additions & 36 deletions
This file was deleted.

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@
2323
B64_IMAGE_CONTENT = base64.b64encode(IMAGE_CONTENT).decode('ascii')
2424

2525

26+
class TestConnection(unittest.TestCase):
27+
28+
@staticmethod
29+
def _get_target_class():
30+
from google.cloud.vision._http import Connection
31+
return Connection
32+
33+
def _make_one(self, *args, **kw):
34+
return self._get_target_class()(*args, **kw)
35+
36+
def test_default_url(self):
37+
client = object()
38+
conn = self._make_one(client)
39+
self.assertEqual(conn._client, client)
40+
41+
2642
class Test_HTTPVisionAPI(unittest.TestCase):
2743
def _get_target_class(self):
2844
from google.cloud.vision._http import _HTTPVisionAPI

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

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)