diff --git a/language/google/cloud/language_v1/gapic/language_service_client.py b/language/google/cloud/language_v1/gapic/language_service_client.py index b4cdae03c39c..e5daf10e6d87 100644 --- a/language/google/cloud/language_v1/gapic/language_service_client.py +++ b/language/google/cloud/language_v1/gapic/language_service_client.py @@ -73,7 +73,7 @@ def __init__(self, transport=None, channel=None, credentials=None, - client_config=language_service_client_config.config, + client_config=None, client_info=None): """Constructor. @@ -106,13 +106,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 = language_service_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 diff --git a/language/google/cloud/language_v1/gapic/transports/language_service_grpc_transport.py b/language/google/cloud/language_v1/gapic/transports/language_service_grpc_transport.py index 7f30da413473..a6f62471a1cd 100644 --- a/language/google/cloud/language_v1/gapic/transports/language_service_grpc_transport.py +++ b/language/google/cloud/language_v1/gapic/transports/language_service_grpc_transport.py @@ -62,6 +62,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 = { @@ -92,6 +94,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 analyze_sentiment(self): """Return the gRPC stub for {$apiMethod.name}. diff --git a/language/google/cloud/language_v1beta2/gapic/language_service_client.py b/language/google/cloud/language_v1beta2/gapic/language_service_client.py index 4bc82b53f3a9..a5215cf38b0a 100644 --- a/language/google/cloud/language_v1beta2/gapic/language_service_client.py +++ b/language/google/cloud/language_v1beta2/gapic/language_service_client.py @@ -73,7 +73,7 @@ def __init__(self, transport=None, channel=None, credentials=None, - client_config=language_service_client_config.config, + client_config=None, client_info=None): """Constructor. @@ -106,13 +106,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 = language_service_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 diff --git a/language/google/cloud/language_v1beta2/gapic/transports/language_service_grpc_transport.py b/language/google/cloud/language_v1beta2/gapic/transports/language_service_grpc_transport.py index 0cf6b652bd25..a8527b3a0a76 100644 --- a/language/google/cloud/language_v1beta2/gapic/transports/language_service_grpc_transport.py +++ b/language/google/cloud/language_v1beta2/gapic/transports/language_service_grpc_transport.py @@ -62,6 +62,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 = { @@ -92,6 +94,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 analyze_sentiment(self): """Return the gRPC stub for {$apiMethod.name}.