Skip to content

Commit dc4834c

Browse files
authored
Add 'client_options' support (via synth). (#8536)
Supersedes #8499.
1 parent c9dff4c commit dc4834c

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

bigquery_storage/google/cloud/bigquery_storage_v1beta1/gapic/big_query_storage_client.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import warnings
2121

2222
from google.oauth2 import service_account
23+
import google.api_core.client_options
2324
import google.api_core.gapic_v1.client_info
2425
import google.api_core.gapic_v1.config
2526
import google.api_core.gapic_v1.method
@@ -86,6 +87,7 @@ def __init__(
8687
credentials=None,
8788
client_config=None,
8889
client_info=None,
90+
client_options=None,
8991
):
9092
"""Constructor.
9193
@@ -116,6 +118,9 @@ def __init__(
116118
API requests. If ``None``, then default info will be used.
117119
Generally, you only need to set this if you're developing
118120
your own client library.
121+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
122+
Client options used to set user options on the client. API Endpoint
123+
should be set through client_options.
119124
"""
120125
# Raise deprecation warnings for things we want to go away.
121126
if client_config is not None:
@@ -134,6 +139,15 @@ def __init__(
134139
stacklevel=2,
135140
)
136141

142+
api_endpoint = self.SERVICE_ADDRESS
143+
if client_options:
144+
if type(client_options) == dict:
145+
client_options = google.api_core.client_options.from_dict(
146+
client_options
147+
)
148+
if client_options.api_endpoint:
149+
api_endpoint = client_options.api_endpoint
150+
137151
# Instantiate the transport.
138152
# The transport is responsible for handling serialization and
139153
# deserialization and actually sending data to the service.
@@ -142,6 +156,7 @@ def __init__(
142156
self.transport = transport(
143157
credentials=credentials,
144158
default_class=big_query_storage_grpc_transport.BigQueryStorageGrpcTransport,
159+
address=api_endpoint,
145160
)
146161
else:
147162
if credentials:
@@ -152,7 +167,7 @@ def __init__(
152167
self.transport = transport
153168
else:
154169
self.transport = big_query_storage_grpc_transport.BigQueryStorageGrpcTransport(
155-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
170+
address=api_endpoint, channel=channel, credentials=credentials
156171
)
157172

158173
if client_info is None:

bigquery_storage/synth.metadata

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
{
2-
"updateTime": "2019-06-26T12:12:55.594550Z",
2+
"updateTime": "2019-06-28T17:48:47.667101Z",
33
"sources": [
44
{
55
"generator": {
66
"name": "artman",
7-
"version": "0.29.0",
8-
"dockerImage": "googleapis/artman@sha256:b79c8c20ee51e5302686c9d1294672d59290df1489be93749ef17d0172cc508d"
7+
"version": "0.29.2",
8+
"dockerImage": "googleapis/artman@sha256:45263333b058a4b3c26a8b7680a2710f43eae3d250f791a6cb66423991dcb2df"
99
}
1010
},
1111
{
1212
"git": {
1313
"name": "googleapis",
1414
"remote": "https://github.com/googleapis/googleapis.git",
15-
"sha": "3a152bcdb544743be7bfc79ebb88b2397a3c4020",
16-
"internalRef": "255067043"
15+
"sha": "84c8ad4e52f8eec8f08a60636cfa597b86969b5c",
16+
"internalRef": "255474859"
1717
}
1818
}
1919
],

bigquery_storage/tests/unit/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def client_under_test(mock_transport):
4141

4242
# The mock is detected as a callable. By creating a real callable here, the
4343
# mock can still be used to verify RPCs.
44-
def transport_callable(credentials=None, default_class=None):
44+
def transport_callable(credentials=None, default_class=None, address=None):
4545
return mock_transport
4646

4747
return client.BigQueryStorageClient(transport=transport_callable)
@@ -50,7 +50,7 @@ def transport_callable(credentials=None, default_class=None):
5050
def test_constructor_w_client_info(mock_transport):
5151
from google.cloud.bigquery_storage_v1beta1 import client
5252

53-
def transport_callable(credentials=None, default_class=None):
53+
def transport_callable(credentials=None, default_class=None, address=None):
5454
return mock_transport
5555

5656
client_under_test = client.BigQueryStorageClient(

0 commit comments

Comments
 (0)