From e8ce14d73862a4fc2f6f635d2373a3b67c92fb11 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Fri, 28 Jun 2019 12:06:45 -0400 Subject: [PATCH] Add 'client_options' support (via synth). --- .../cloud/speech_v1/gapic/speech_client.py | 17 ++++++++++++++++- .../speech_v1p1beta1/gapic/speech_client.py | 17 ++++++++++++++++- speech/synth.metadata | 10 +++++----- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/speech/google/cloud/speech_v1/gapic/speech_client.py b/speech/google/cloud/speech_v1/gapic/speech_client.py index b40ffec6e080..7bbd7ec989d8 100644 --- a/speech/google/cloud/speech_v1/gapic/speech_client.py +++ b/speech/google/cloud/speech_v1/gapic/speech_client.py @@ -20,6 +20,7 @@ import warnings from google.oauth2 import service_account +import google.api_core.client_options import google.api_core.gapic_v1.client_info import google.api_core.gapic_v1.config import google.api_core.gapic_v1.method @@ -77,6 +78,7 @@ def __init__( credentials=None, client_config=None, client_info=None, + client_options=None, ): """Constructor. @@ -107,6 +109,9 @@ def __init__( API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. + client_options (Union[dict, google.api_core.client_options.ClientOptions]): + Client options used to set user options on the client. API Endpoint + should be set through client_options. """ # Raise deprecation warnings for things we want to go away. if client_config is not None: @@ -125,6 +130,15 @@ def __init__( stacklevel=2, ) + api_endpoint = self.SERVICE_ADDRESS + if client_options: + if type(client_options) == dict: + client_options = google.api_core.client_options.from_dict( + client_options + ) + if client_options.api_endpoint: + api_endpoint = client_options.api_endpoint + # Instantiate the transport. # The transport is responsible for handling serialization and # deserialization and actually sending data to the service. @@ -133,6 +147,7 @@ def __init__( self.transport = transport( credentials=credentials, default_class=speech_grpc_transport.SpeechGrpcTransport, + address=api_endpoint, ) else: if credentials: @@ -143,7 +158,7 @@ def __init__( self.transport = transport else: self.transport = speech_grpc_transport.SpeechGrpcTransport( - address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials + address=api_endpoint, channel=channel, credentials=credentials ) if client_info is None: diff --git a/speech/google/cloud/speech_v1p1beta1/gapic/speech_client.py b/speech/google/cloud/speech_v1p1beta1/gapic/speech_client.py index e3f6828410f2..f84fcf1007a5 100644 --- a/speech/google/cloud/speech_v1p1beta1/gapic/speech_client.py +++ b/speech/google/cloud/speech_v1p1beta1/gapic/speech_client.py @@ -20,6 +20,7 @@ import warnings from google.oauth2 import service_account +import google.api_core.client_options import google.api_core.gapic_v1.client_info import google.api_core.gapic_v1.config import google.api_core.gapic_v1.method @@ -77,6 +78,7 @@ def __init__( credentials=None, client_config=None, client_info=None, + client_options=None, ): """Constructor. @@ -107,6 +109,9 @@ def __init__( API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. + client_options (Union[dict, google.api_core.client_options.ClientOptions]): + Client options used to set user options on the client. API Endpoint + should be set through client_options. """ # Raise deprecation warnings for things we want to go away. if client_config is not None: @@ -125,6 +130,15 @@ def __init__( stacklevel=2, ) + api_endpoint = self.SERVICE_ADDRESS + if client_options: + if type(client_options) == dict: + client_options = google.api_core.client_options.from_dict( + client_options + ) + if client_options.api_endpoint: + api_endpoint = client_options.api_endpoint + # Instantiate the transport. # The transport is responsible for handling serialization and # deserialization and actually sending data to the service. @@ -133,6 +147,7 @@ def __init__( self.transport = transport( credentials=credentials, default_class=speech_grpc_transport.SpeechGrpcTransport, + address=api_endpoint, ) else: if credentials: @@ -143,7 +158,7 @@ def __init__( self.transport = transport else: self.transport = speech_grpc_transport.SpeechGrpcTransport( - address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials + address=api_endpoint, channel=channel, credentials=credentials ) if client_info is None: diff --git a/speech/synth.metadata b/speech/synth.metadata index 3280b3246a70..c5c5005fedb2 100644 --- a/speech/synth.metadata +++ b/speech/synth.metadata @@ -1,19 +1,19 @@ { - "updateTime": "2019-06-27T12:32:29.254377Z", + "updateTime": "2019-06-28T15:50:18.655495Z", "sources": [ { "generator": { "name": "artman", - "version": "0.29.1", - "dockerImage": "googleapis/artman@sha256:b2a73f4dda03ef8fcaa973e3ba26d0cf34091f6c22c70add663af325931aef4d" + "version": "0.29.2", + "dockerImage": "googleapis/artman@sha256:45263333b058a4b3c26a8b7680a2710f43eae3d250f791a6cb66423991dcb2df" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "f46206aff84f4b2cde590f1e0791112214f07080", - "internalRef": "255318896" + "sha": "84c8ad4e52f8eec8f08a60636cfa597b86969b5c", + "internalRef": "255474859" } }, {