File tree Expand file tree Collapse file tree
packages/google-cloud-vision Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313# limitations under the License.
1414
1515"""Google Cloud Vision API package."""
16+
1617from google .cloud .vision .client import Client
Original file line number Diff line number Diff line change 1414
1515"""HTTP Client for interacting with the Google Cloud Vision API."""
1616
17+ from google .cloud import _http
18+
1719from google .cloud .vision .annotations import Annotations
1820from 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+
2140class _HTTPVisionAPI (object ):
2241 """Vision API for interacting with the JSON/HTTP version of Vision
2342
Original file line number Diff line number Diff line change 2020from google .cloud .environment_vars import DISABLE_GRPC
2121
2222from google .cloud .vision ._gax import _GAPICVisionAPI
23+ from google .cloud .vision ._http import _HTTPVisionAPI
24+ from google .cloud .vision ._http import Connection
2325from google .cloud .vision .batch import Batch
24- from google .cloud .vision .connection import Connection
2526from 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 )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 2323B64_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+
2642class Test_HTTPVisionAPI (unittest .TestCase ):
2743 def _get_target_class (self ):
2844 from google .cloud .vision ._http import _HTTPVisionAPI
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments