Skip to content

Conversation

@daspecster
Copy link
Contributor

Towards #2753 for adding GAPIC support.

Separates out the REST client in preparation to add the GAPIC client alongside.

@daspecster daspecster added the api: vision Issues related to the Cloud Vision API. label Dec 8, 2016
@daspecster daspecster requested review from dhermes and tseaver December 8, 2016 21:08
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Dec 8, 2016
@@ -0,0 +1,91 @@
# Copyright 2016 Google Inc.

This comment was marked as spam.

from google.cloud.vision.feature import Feature


class _RESTVisionAPI(object):

This comment was marked as spam.

# See the License for the specific language governing permissions and
# limitations under the License.

"""REST Client for interacting with the Google Cloud Vision API."""

This comment was marked as spam.

if isinstance(features, list):
self._features.extend(features)
elif isinstance(features, Feature):
self._features.append(features)

This comment was marked as spam.

return response['responses'][0]


class VisionRequest(object):

This comment was marked as spam.

response = self._connection.api_request(
method='POST', path='/images:annotate', data=data)

return response['responses'][0]

This comment was marked as spam.

source_uri=source_uri)

@property
def vision_api(self):

This comment was marked as spam.

@tseaver tseaver changed the title Separate REST client. Separate HTTP client. Dec 9, 2016
features = [features]

feature_check = (isinstance(feature, Feature) for feature in features)
if not isinstance(features, list) or not any(feature_check):

This comment was marked as spam.


return {
'image': image.as_dict(),
'features': [feature.as_dict() for feature in features]

This comment was marked as spam.

from google.cloud.vision.image import Image

credentials = _make_credentials()
client = Client(project=PROJECT, credentials=credentials)

This comment was marked as spam.


class MockVisionAPI(object):
def annotate(self):
return True

This comment was marked as spam.

@daspecster
Copy link
Contributor Author

@dhermes is this all set?

@dhermes
Copy link
Contributor

dhermes commented Dec 15, 2016

Yes, though it seems the rebase of #2870 into this would be easier than the other way around. WDYT?

@daspecster
Copy link
Contributor Author

Sure, I can wait for #2870. I'll squash this for now and merge once #2870 and probably #2874 are merged to master.

@daspecster daspecster force-pushed the vision-separate-rest-client branch from 23fd960 to fb6f7f8 Compare December 15, 2016 20:02
@dhermes
Copy link
Contributor

dhermes commented Dec 15, 2016

Luckily #2874 won't conflict here

@daspecster
Copy link
Contributor Author

@dhermes yeah I just looked through #2874. SGTM! Will merge after #2870.

@daspecster daspecster force-pushed the vision-separate-rest-client branch from fb6f7f8 to 74e537b Compare December 15, 2016 20:33
@daspecster
Copy link
Contributor Author

Rebased and squashed. Will merge once build passes.

@dhermes
Copy link
Contributor

dhermes commented Dec 15, 2016

SGTM

@daspecster daspecster merged commit f4c3025 into googleapis:master Dec 15, 2016
@daspecster daspecster deleted the vision-separate-rest-client branch December 15, 2016 20:56
richkadel pushed a commit to richkadel/google-cloud-python that referenced this pull request May 6, 2017
parthea pushed a commit that referenced this pull request Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: vision Issues related to the Cloud Vision API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants