Uh oh!
There was an error while loading. Please reload this page.
Separate HTTP client. - #2845
Conversation
| @@ -0,0 +1,91 @@ | |||
| # Copyright 2016 Google Inc. | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| from google.cloud.vision.feature import Feature | ||
| class _RESTVisionAPI(object): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| # 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.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| if isinstance(features, list): | ||
| self._features.extend(features) | ||
| elif isinstance(features, Feature): | ||
| self._features.append(features) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| return response['responses'][0] | ||
| class VisionRequest(object): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| response = self._connection.api_request( | ||
| method='POST', path='/images:annotate', data=data) | ||
| return response['responses'][0] |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| source_uri=source_uri) | ||
| @property | ||
| def vision_api(self): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| 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.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| return { | ||
| 'image': image.as_dict(), | ||
| 'features': [feature.as_dict() for feature in features] |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| from google.cloud.vision.image import Image | ||
| credentials = _make_credentials() | ||
| client = Client(project=PROJECT, credentials=credentials) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| class MockVisionAPI(object): | ||
| def annotate(self): | ||
| return True |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
daspecster
commented
Dec 15, 2016
@dhermes is this all set? |
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
commented
Dec 15, 2016
23fd960 to
fb6f7f8Comparedhermes
commented
Dec 15, 2016
Luckily #2874 won't conflict here |
daspecster
commented
Dec 15, 2016
fb6f7f8 to
74e537bComparedaspecster
commented
Dec 15, 2016
Rebased and squashed. Will merge once build passes. |
dhermes
commented
Dec 15, 2016
SGTM |
…st-client Separate HTTP client.
Towards #2753 for adding GAPIC support.
Separates out the REST client in preparation to add the GAPIC client alongside.