From 43e41fb31b434e77526d0131621fdc619cff9238 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 28 Jun 2019 08:57:42 -0700 Subject: [PATCH] Add 'client_options' support (via synth). (#8498) --- .../asset_v1/gapic/asset_service_client.py | 17 ++++++++++++++++- .../asset_v1beta1/gapic/asset_service_client.py | 17 ++++++++++++++++- asset/synth.metadata | 10 +++++----- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/asset/google/cloud/asset_v1/gapic/asset_service_client.py b/asset/google/cloud/asset_v1/gapic/asset_service_client.py index fb9029fa385c..ff04f6f9bb18 100644 --- a/asset/google/cloud/asset_v1/gapic/asset_service_client.py +++ b/asset/google/cloud/asset_v1/gapic/asset_service_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 @@ -87,6 +88,7 @@ def __init__( credentials=None, client_config=None, client_info=None, + client_options=None, ): """Constructor. @@ -117,6 +119,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: @@ -135,6 +140,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. @@ -143,6 +157,7 @@ def __init__( self.transport = transport( credentials=credentials, default_class=asset_service_grpc_transport.AssetServiceGrpcTransport, + address=api_endpoint, ) else: if credentials: @@ -153,7 +168,7 @@ def __init__( self.transport = transport else: self.transport = asset_service_grpc_transport.AssetServiceGrpcTransport( - address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials + address=api_endpoint, channel=channel, credentials=credentials ) if client_info is None: diff --git a/asset/google/cloud/asset_v1beta1/gapic/asset_service_client.py b/asset/google/cloud/asset_v1beta1/gapic/asset_service_client.py index 52b09dc69ed4..45e8de4cd3fe 100644 --- a/asset/google/cloud/asset_v1beta1/gapic/asset_service_client.py +++ b/asset/google/cloud/asset_v1beta1/gapic/asset_service_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 @@ -87,6 +88,7 @@ def __init__( credentials=None, client_config=None, client_info=None, + client_options=None, ): """Constructor. @@ -117,6 +119,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: @@ -135,6 +140,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. @@ -143,6 +157,7 @@ def __init__( self.transport = transport( credentials=credentials, default_class=asset_service_grpc_transport.AssetServiceGrpcTransport, + address=api_endpoint, ) else: if credentials: @@ -153,7 +168,7 @@ def __init__( self.transport = transport else: self.transport = asset_service_grpc_transport.AssetServiceGrpcTransport( - address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials + address=api_endpoint, channel=channel, credentials=credentials ) if client_info is None: diff --git a/asset/synth.metadata b/asset/synth.metadata index 939ae8b160ae..17238865db59 100644 --- a/asset/synth.metadata +++ b/asset/synth.metadata @@ -1,19 +1,19 @@ { - "updateTime": "2019-06-18T12:11:09.043902Z", + "updateTime": "2019-06-28T12:11:08.346628Z", "sources": [ { "generator": { "name": "artman", - "version": "0.27.0", - "dockerImage": "googleapis/artman@sha256:b036a7f4278d9deb5796f065e5c7f608d47d75369985ca7ab5039998120e972d" + "version": "0.29.2", + "dockerImage": "googleapis/artman@sha256:45263333b058a4b3c26a8b7680a2710f43eae3d250f791a6cb66423991dcb2df" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "384aa843867c4d17756d14a01f047b6368494d32", - "internalRef": "253675319" + "sha": "84c8ad4e52f8eec8f08a60636cfa597b86969b5c", + "internalRef": "255474859" } }, {