Skip to content

Commit 4045c3f

Browse files
yoshi-automationtseaver
authored andcommitted
Add 'client_options' support (via synth). (#8515)
1 parent 6204242 commit 4045c3f

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

language/google/cloud/language_v1/gapic/language_service_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
@@ -76,6 +77,7 @@ def __init__(
7677
credentials=None,
7778
client_config=None,
7879
client_info=None,
80+
client_options=None,
7981
):
8082
"""Constructor.
8183
@@ -106,6 +108,9 @@ def __init__(
106108
API requests. If ``None``, then default info will be used.
107109
Generally, you only need to set this if you're developing
108110
your own client library.
111+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
112+
Client options used to set user options on the client. API Endpoint
113+
should be set through client_options.
109114
"""
110115
# Raise deprecation warnings for things we want to go away.
111116
if client_config is not None:
@@ -124,6 +129,15 @@ def __init__(
124129
stacklevel=2,
125130
)
126131

132+
api_endpoint = self.SERVICE_ADDRESS
133+
if client_options:
134+
if type(client_options) == dict:
135+
client_options = google.api_core.client_options.from_dict(
136+
client_options
137+
)
138+
if client_options.api_endpoint:
139+
api_endpoint = client_options.api_endpoint
140+
127141
# Instantiate the transport.
128142
# The transport is responsible for handling serialization and
129143
# deserialization and actually sending data to the service.
@@ -132,6 +146,7 @@ def __init__(
132146
self.transport = transport(
133147
credentials=credentials,
134148
default_class=language_service_grpc_transport.LanguageServiceGrpcTransport,
149+
address=api_endpoint,
135150
)
136151
else:
137152
if credentials:
@@ -142,7 +157,7 @@ def __init__(
142157
self.transport = transport
143158
else:
144159
self.transport = language_service_grpc_transport.LanguageServiceGrpcTransport(
145-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
160+
address=api_endpoint, channel=channel, credentials=credentials
146161
)
147162

148163
if client_info is None:

language/google/cloud/language_v1beta2/gapic/language_service_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
@@ -78,6 +79,7 @@ def __init__(
7879
credentials=None,
7980
client_config=None,
8081
client_info=None,
82+
client_options=None,
8183
):
8284
"""Constructor.
8385
@@ -108,6 +110,9 @@ def __init__(
108110
API requests. If ``None``, then default info will be used.
109111
Generally, you only need to set this if you're developing
110112
your own client library.
113+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
114+
Client options used to set user options on the client. API Endpoint
115+
should be set through client_options.
111116
"""
112117
# Raise deprecation warnings for things we want to go away.
113118
if client_config is not None:
@@ -126,6 +131,15 @@ def __init__(
126131
stacklevel=2,
127132
)
128133

134+
api_endpoint = self.SERVICE_ADDRESS
135+
if client_options:
136+
if type(client_options) == dict:
137+
client_options = google.api_core.client_options.from_dict(
138+
client_options
139+
)
140+
if client_options.api_endpoint:
141+
api_endpoint = client_options.api_endpoint
142+
129143
# Instantiate the transport.
130144
# The transport is responsible for handling serialization and
131145
# deserialization and actually sending data to the service.
@@ -134,6 +148,7 @@ def __init__(
134148
self.transport = transport(
135149
credentials=credentials,
136150
default_class=language_service_grpc_transport.LanguageServiceGrpcTransport,
151+
address=api_endpoint,
137152
)
138153
else:
139154
if credentials:
@@ -144,7 +159,7 @@ def __init__(
144159
self.transport = transport
145160
else:
146161
self.transport = language_service_grpc_transport.LanguageServiceGrpcTransport(
147-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
162+
address=api_endpoint, channel=channel, credentials=credentials
148163
)
149164

150165
if client_info is None:

language/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-18T12:22:11.560149Z",
2+
"updateTime": "2019-06-28T12:28:08.876928Z",
33
"sources": [
44
{
55
"generator": {
66
"name": "artman",
7-
"version": "0.27.0",
8-
"dockerImage": "googleapis/artman@sha256:b036a7f4278d9deb5796f065e5c7f608d47d75369985ca7ab5039998120e972d"
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": "384aa843867c4d17756d14a01f047b6368494d32",
16-
"internalRef": "253675319"
15+
"sha": "84c8ad4e52f8eec8f08a60636cfa597b86969b5c",
16+
"internalRef": "255474859"
1717
}
1818
},
1919
{

0 commit comments

Comments
 (0)