Skip to content

Commit

Permalink
Vision: pick up fixes to GAPIC generator. (googleapis#6632)
Browse files Browse the repository at this point in the history
Includes fixes from these PRs:

- googleapis/gapic-generator#2407
- googleapis/gapic-generator#2396

Includes changes to generated tests.

Closes googleapis#6475.
  • Loading branch information
tseaver authored and Erik Webb committed Dec 3, 2018
1 parent 1535f81 commit 3fcbd7b
Show file tree
Hide file tree
Showing 21 changed files with 600 additions and 227 deletions.
17 changes: 12 additions & 5 deletions vision/google/cloud/vision_v1/gapic/image_annotator_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __init__(self,
transport=None,
channel=None,
credentials=None,
client_config=image_annotator_client_config.config,
client_config=None,
client_info=None):
"""Constructor.
Expand Down Expand Up @@ -114,13 +114,20 @@ def __init__(self,
your own client library.
"""
# Raise deprecation warnings for things we want to go away.
if client_config:
warnings.warn('The `client_config` argument is deprecated.',
PendingDeprecationWarning)
if client_config is not None:
warnings.warn(
'The `client_config` argument is deprecated.',
PendingDeprecationWarning,
stacklevel=2)
else:
client_config = image_annotator_client_config.config

if channel:
warnings.warn(
'The `channel` argument is deprecated; use '
'`transport` instead.', PendingDeprecationWarning)
'`transport` instead.',
PendingDeprecationWarning,
stacklevel=2)

# Instantiate the transport.
# The transport is responsible for handling serialization and
Expand Down
49 changes: 28 additions & 21 deletions vision/google/cloud/vision_v1/gapic/product_search_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,41 +99,41 @@ def location_path(cls, project, location):
)

@classmethod
def product_path(cls, project, location, product):
"""Return a fully-qualified product string."""
def product_set_path(cls, project, location, product_set):
"""Return a fully-qualified product_set string."""
return google.api_core.path_template.expand(
'projects/{project}/locations/{location}/products/{product}',
'projects/{project}/locations/{location}/productSets/{product_set}',
project=project,
location=location,
product=product,
product_set=product_set,
)

@classmethod
def product_set_path(cls, project, location, product_set):
"""Return a fully-qualified product_set string."""
def product_path(cls, project, location, product):
"""Return a fully-qualified product string."""
return google.api_core.path_template.expand(
'projects/{project}/locations/{location}/productSets/{product_set}',
'projects/{project}/locations/{location}/products/{product}',
project=project,
location=location,
product_set=product_set,
product=product,
)

@classmethod
def image_path(cls, project, location, product, image):
"""Return a fully-qualified image string."""
def reference_image_path(cls, project, location, product, reference_image):
"""Return a fully-qualified reference_image string."""
return google.api_core.path_template.expand(
'projects/{project}/locations/{location}/products/{product}/referenceImages/{image}',
'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}',
project=project,
location=location,
product=product,
image=image,
reference_image=reference_image,
)

def __init__(self,
transport=None,
channel=None,
credentials=None,
client_config=product_search_client_config.config,
client_config=None,
client_info=None):
"""Constructor.
Expand Down Expand Up @@ -166,13 +166,20 @@ def __init__(self,
your own client library.
"""
# Raise deprecation warnings for things we want to go away.
if client_config:
warnings.warn('The `client_config` argument is deprecated.',
PendingDeprecationWarning)
if client_config is not None:
warnings.warn(
'The `client_config` argument is deprecated.',
PendingDeprecationWarning,
stacklevel=2)
else:
client_config = product_search_client_config.config

if channel:
warnings.warn(
'The `channel` argument is deprecated; use '
'`transport` instead.', PendingDeprecationWarning)
'`transport` instead.',
PendingDeprecationWarning,
stacklevel=2)

# Instantiate the transport.
# The transport is responsible for handling serialization and
Expand Down Expand Up @@ -707,7 +714,7 @@ def get_reference_image(self,
>>>
>>> client = vision_v1.ProductSearchClient()
>>>
>>> name = client.image_path('[PROJECT]', '[LOCATION]', '[PRODUCT]', '[IMAGE]')
>>> name = client.reference_image_path('[PROJECT]', '[LOCATION]', '[PRODUCT]', '[REFERENCE_IMAGE]')
>>>
>>> response = client.get_reference_image(name)
Expand Down Expand Up @@ -776,7 +783,7 @@ def delete_reference_image(self,
>>>
>>> client = vision_v1.ProductSearchClient()
>>>
>>> name = client.image_path('[PROJECT]', '[LOCATION]', '[PRODUCT]', '[IMAGE]')
>>> name = client.reference_image_path('[PROJECT]', '[LOCATION]', '[PRODUCT]', '[REFERENCE_IMAGE]')
>>>
>>> client.delete_reference_image(name)
Expand Down Expand Up @@ -1228,8 +1235,8 @@ def delete_product_set(self,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None):
"""
Permanently deletes a ProductSet. All Products and ReferenceImages in
the ProductSet will be deleted.
Permanently deletes a ProductSet. Products and ReferenceImages in the
ProductSet are not deleted.
The actual image files are not deleted from Google Cloud Storage.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def __init__(self,
credentials=credentials,
)

self._channel = channel

# gRPC uses objects called "stubs" that are bound to the
# channel and provide a basic method for each RPC.
self._stubs = {
Expand Down Expand Up @@ -102,6 +104,15 @@ def create_channel(cls,
scopes=cls._OAUTH_SCOPES,
)

@property
def channel(self):
"""The gRPC channel used by the transport.
Returns:
grpc.Channel: A gRPC channel object.
"""
return self._channel

@property
def batch_annotate_images(self):
"""Return the gRPC stub for {$apiMethod.name}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def __init__(self,
credentials=credentials,
)

self._channel = channel

# gRPC uses objects called "stubs" that are bound to the
# channel and provide a basic method for each RPC.
self._stubs = {
Expand Down Expand Up @@ -102,6 +104,15 @@ def create_channel(cls,
scopes=cls._OAUTH_SCOPES,
)

@property
def channel(self):
"""The gRPC channel used by the transport.
Returns:
grpc.Channel: A gRPC channel object.
"""
return self._channel

@property
def create_product(self):
"""Return the gRPC stub for {$apiMethod.name}.
Expand Down Expand Up @@ -375,8 +386,8 @@ def update_product_set(self):
def delete_product_set(self):
"""Return the gRPC stub for {$apiMethod.name}.
Permanently deletes a ProductSet. All Products and ReferenceImages in
the ProductSet will be deleted.
Permanently deletes a ProductSet. Products and ReferenceImages in the
ProductSet are not deleted.
The actual image files are not deleted from Google Cloud Storage.
Expand Down
161 changes: 81 additions & 80 deletions vision/google/cloud/vision_v1/proto/image_annotator_pb2.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ def UpdateProductSet(self, request, context):
raise NotImplementedError('Method not implemented!')

def DeleteProductSet(self, request, context):
"""Permanently deletes a ProductSet. All Products and ReferenceImages in the
ProductSet will be deleted.
"""Permanently deletes a ProductSet. Products and ReferenceImages in the
ProductSet are not deleted.
The actual image files are not deleted from Google Cloud Storage.
Expand Down
6 changes: 3 additions & 3 deletions vision/google/cloud/vision_v1/proto/text_annotation_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(self,
transport=None,
channel=None,
credentials=None,
client_config=image_annotator_client_config.config,
client_config=None,
client_info=None):
"""Constructor.
Expand Down Expand Up @@ -107,13 +107,20 @@ def __init__(self,
your own client library.
"""
# Raise deprecation warnings for things we want to go away.
if client_config:
warnings.warn('The `client_config` argument is deprecated.',
PendingDeprecationWarning)
if client_config is not None:
warnings.warn(
'The `client_config` argument is deprecated.',
PendingDeprecationWarning,
stacklevel=2)
else:
client_config = image_annotator_client_config.config

if channel:
warnings.warn(
'The `channel` argument is deprecated; use '
'`transport` instead.', PendingDeprecationWarning)
'`transport` instead.',
PendingDeprecationWarning,
stacklevel=2)

# Instantiate the transport.
# The transport is responsible for handling serialization and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def __init__(self,
credentials=credentials,
)

self._channel = channel

# gRPC uses objects called "stubs" that are bound to the
# channel and provide a basic method for each RPC.
self._stubs = {
Expand Down Expand Up @@ -95,6 +97,15 @@ def create_channel(cls,
scopes=cls._OAUTH_SCOPES,
)

@property
def channel(self):
"""The gRPC channel used by the transport.
Returns:
grpc.Channel: A gRPC channel object.
"""
return self._channel

@property
def batch_annotate_images(self):
"""Return the gRPC stub for {$apiMethod.name}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(self,
transport=None,
channel=None,
credentials=None,
client_config=image_annotator_client_config.config,
client_config=None,
client_info=None):
"""Constructor.
Expand Down Expand Up @@ -110,13 +110,20 @@ def __init__(self,
your own client library.
"""
# Raise deprecation warnings for things we want to go away.
if client_config:
warnings.warn('The `client_config` argument is deprecated.',
PendingDeprecationWarning)
if client_config is not None:
warnings.warn(
'The `client_config` argument is deprecated.',
PendingDeprecationWarning,
stacklevel=2)
else:
client_config = image_annotator_client_config.config

if channel:
warnings.warn(
'The `channel` argument is deprecated; use '
'`transport` instead.', PendingDeprecationWarning)
'`transport` instead.',
PendingDeprecationWarning,
stacklevel=2)

# Instantiate the transport.
# The transport is responsible for handling serialization and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def __init__(self,
credentials=credentials,
)

self._channel = channel

# gRPC uses objects called "stubs" that are bound to the
# channel and provide a basic method for each RPC.
self._stubs = {
Expand Down Expand Up @@ -102,6 +104,15 @@ def create_channel(cls,
scopes=cls._OAUTH_SCOPES,
)

@property
def channel(self):
"""The gRPC channel used by the transport.
Returns:
grpc.Channel: A gRPC channel object.
"""
return self._channel

@property
def batch_annotate_images(self):
"""Return the gRPC stub for {$apiMethod.name}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __init__(self,
transport=None,
channel=None,
credentials=None,
client_config=image_annotator_client_config.config,
client_config=None,
client_info=None):
"""Constructor.
Expand Down Expand Up @@ -114,13 +114,20 @@ def __init__(self,
your own client library.
"""
# Raise deprecation warnings for things we want to go away.
if client_config:
warnings.warn('The `client_config` argument is deprecated.',
PendingDeprecationWarning)
if client_config is not None:
warnings.warn(
'The `client_config` argument is deprecated.',
PendingDeprecationWarning,
stacklevel=2)
else:
client_config = image_annotator_client_config.config

if channel:
warnings.warn(
'The `channel` argument is deprecated; use '
'`transport` instead.', PendingDeprecationWarning)
'`transport` instead.',
PendingDeprecationWarning,
stacklevel=2)

# Instantiate the transport.
# The transport is responsible for handling serialization and
Expand Down
Loading

0 comments on commit 3fcbd7b

Please sign in to comment.