Skip to content

Commit 768dcc0

Browse files
yoshi-automationbusunkim96
authored andcommitted
Add 'client_options' support, update list method docstrings (via synth). (#8522)
1 parent 4045c3f commit 768dcc0

File tree

4 files changed

+69
-24
lines changed

4 files changed

+69
-24
lines changed

spanner/google/cloud/spanner_admin_database_v1/gapic/database_admin_client.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import warnings
2222

2323
from google.oauth2 import service_account
24+
import google.api_core.client_options
2425
import google.api_core.gapic_v1.client_info
2526
import google.api_core.gapic_v1.config
2627
import google.api_core.gapic_v1.method
@@ -110,6 +111,7 @@ def __init__(
110111
credentials=None,
111112
client_config=None,
112113
client_info=None,
114+
client_options=None,
113115
):
114116
"""Constructor.
115117
@@ -140,6 +142,9 @@ def __init__(
140142
API requests. If ``None``, then default info will be used.
141143
Generally, you only need to set this if you're developing
142144
your own client library.
145+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
146+
Client options used to set user options on the client. API Endpoint
147+
should be set through client_options.
143148
"""
144149
# Raise deprecation warnings for things we want to go away.
145150
if client_config is not None:
@@ -158,6 +163,15 @@ def __init__(
158163
stacklevel=2,
159164
)
160165

166+
api_endpoint = self.SERVICE_ADDRESS
167+
if client_options:
168+
if type(client_options) == dict:
169+
client_options = google.api_core.client_options.from_dict(
170+
client_options
171+
)
172+
if client_options.api_endpoint:
173+
api_endpoint = client_options.api_endpoint
174+
161175
# Instantiate the transport.
162176
# The transport is responsible for handling serialization and
163177
# deserialization and actually sending data to the service.
@@ -166,6 +180,7 @@ def __init__(
166180
self.transport = transport(
167181
credentials=credentials,
168182
default_class=database_admin_grpc_transport.DatabaseAdminGrpcTransport,
183+
address=api_endpoint,
169184
)
170185
else:
171186
if credentials:
@@ -176,7 +191,7 @@ def __init__(
176191
self.transport = transport
177192
else:
178193
self.transport = database_admin_grpc_transport.DatabaseAdminGrpcTransport(
179-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
194+
address=api_endpoint, channel=channel, credentials=credentials
180195
)
181196

182197
if client_info is None:
@@ -252,10 +267,10 @@ def list_databases(
252267
that is provided to the method.
253268
254269
Returns:
255-
A :class:`~google.gax.PageIterator` instance. By default, this
256-
is an iterable of :class:`~google.cloud.spanner_admin_database_v1.types.Database` instances.
257-
This object can also be configured to iterate over the pages
258-
of the response through the `options` parameter.
270+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
271+
An iterable of :class:`~google.cloud.spanner_admin_database_v1.types.Database` instances.
272+
You can also iterate over the pages of the response
273+
using its `pages` property.
259274
260275
Raises:
261276
google.api_core.exceptions.GoogleAPICallError: If the request

spanner/google/cloud/spanner_admin_instance_v1/gapic/instance_admin_client.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import warnings
2222

2323
from google.oauth2 import service_account
24+
import google.api_core.client_options
2425
import google.api_core.gapic_v1.client_info
2526
import google.api_core.gapic_v1.config
2627
import google.api_core.gapic_v1.method
@@ -133,6 +134,7 @@ def __init__(
133134
credentials=None,
134135
client_config=None,
135136
client_info=None,
137+
client_options=None,
136138
):
137139
"""Constructor.
138140
@@ -163,6 +165,9 @@ def __init__(
163165
API requests. If ``None``, then default info will be used.
164166
Generally, you only need to set this if you're developing
165167
your own client library.
168+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
169+
Client options used to set user options on the client. API Endpoint
170+
should be set through client_options.
166171
"""
167172
# Raise deprecation warnings for things we want to go away.
168173
if client_config is not None:
@@ -181,6 +186,15 @@ def __init__(
181186
stacklevel=2,
182187
)
183188

189+
api_endpoint = self.SERVICE_ADDRESS
190+
if client_options:
191+
if type(client_options) == dict:
192+
client_options = google.api_core.client_options.from_dict(
193+
client_options
194+
)
195+
if client_options.api_endpoint:
196+
api_endpoint = client_options.api_endpoint
197+
184198
# Instantiate the transport.
185199
# The transport is responsible for handling serialization and
186200
# deserialization and actually sending data to the service.
@@ -189,6 +203,7 @@ def __init__(
189203
self.transport = transport(
190204
credentials=credentials,
191205
default_class=instance_admin_grpc_transport.InstanceAdminGrpcTransport,
206+
address=api_endpoint,
192207
)
193208
else:
194209
if credentials:
@@ -199,7 +214,7 @@ def __init__(
199214
self.transport = transport
200215
else:
201216
self.transport = instance_admin_grpc_transport.InstanceAdminGrpcTransport(
202-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
217+
address=api_endpoint, channel=channel, credentials=credentials
203218
)
204219

205220
if client_info is None:
@@ -276,10 +291,10 @@ def list_instance_configs(
276291
that is provided to the method.
277292
278293
Returns:
279-
A :class:`~google.gax.PageIterator` instance. By default, this
280-
is an iterable of :class:`~google.cloud.spanner_admin_instance_v1.types.InstanceConfig` instances.
281-
This object can also be configured to iterate over the pages
282-
of the response through the `options` parameter.
294+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
295+
An iterable of :class:`~google.cloud.spanner_admin_instance_v1.types.InstanceConfig` instances.
296+
You can also iterate over the pages of the response
297+
using its `pages` property.
283298
284299
Raises:
285300
google.api_core.exceptions.GoogleAPICallError: If the request
@@ -469,10 +484,10 @@ def list_instances(
469484
that is provided to the method.
470485
471486
Returns:
472-
A :class:`~google.gax.PageIterator` instance. By default, this
473-
is an iterable of :class:`~google.cloud.spanner_admin_instance_v1.types.Instance` instances.
474-
This object can also be configured to iterate over the pages
475-
of the response through the `options` parameter.
487+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
488+
An iterable of :class:`~google.cloud.spanner_admin_instance_v1.types.Instance` instances.
489+
You can also iterate over the pages of the response
490+
using its `pages` property.
476491
477492
Raises:
478493
google.api_core.exceptions.GoogleAPICallError: If the request

spanner/google/cloud/spanner_v1/gapic/spanner_client.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import warnings
2222

2323
from google.oauth2 import service_account
24+
import google.api_core.client_options
2425
import google.api_core.gapic_v1.client_info
2526
import google.api_core.gapic_v1.config
2627
import google.api_core.gapic_v1.method
@@ -110,6 +111,7 @@ def __init__(
110111
credentials=None,
111112
client_config=None,
112113
client_info=None,
114+
client_options=None,
113115
):
114116
"""Constructor.
115117
@@ -140,6 +142,9 @@ def __init__(
140142
API requests. If ``None``, then default info will be used.
141143
Generally, you only need to set this if you're developing
142144
your own client library.
145+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
146+
Client options used to set user options on the client. API Endpoint
147+
should be set through client_options.
143148
"""
144149
# Raise deprecation warnings for things we want to go away.
145150
if client_config is not None:
@@ -158,6 +163,15 @@ def __init__(
158163
stacklevel=2,
159164
)
160165

166+
api_endpoint = self.SERVICE_ADDRESS
167+
if client_options:
168+
if type(client_options) == dict:
169+
client_options = google.api_core.client_options.from_dict(
170+
client_options
171+
)
172+
if client_options.api_endpoint:
173+
api_endpoint = client_options.api_endpoint
174+
161175
# Instantiate the transport.
162176
# The transport is responsible for handling serialization and
163177
# deserialization and actually sending data to the service.
@@ -166,6 +180,7 @@ def __init__(
166180
self.transport = transport(
167181
credentials=credentials,
168182
default_class=spanner_grpc_transport.SpannerGrpcTransport,
183+
address=api_endpoint,
169184
)
170185
else:
171186
if credentials:
@@ -176,7 +191,7 @@ def __init__(
176191
self.transport = transport
177192
else:
178193
self.transport = spanner_grpc_transport.SpannerGrpcTransport(
179-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
194+
address=api_endpoint, channel=channel, credentials=credentials
180195
)
181196

182197
if client_info is None:
@@ -422,10 +437,10 @@ def list_sessions(
422437
that is provided to the method.
423438
424439
Returns:
425-
A :class:`~google.gax.PageIterator` instance. By default, this
426-
is an iterable of :class:`~google.cloud.spanner_v1.types.Session` instances.
427-
This object can also be configured to iterate over the pages
428-
of the response through the `options` parameter.
440+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
441+
An iterable of :class:`~google.cloud.spanner_v1.types.Session` instances.
442+
You can also iterate over the pages of the response
443+
using its `pages` property.
429444
430445
Raises:
431446
google.api_core.exceptions.GoogleAPICallError: If the request

spanner/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-20T12:28:03.852119Z",
2+
"updateTime": "2019-06-28T12:34:35.657138Z",
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": "45e125f9e30dc5d45b52752b3ab78dd4f6084f2d",
16-
"internalRef": "254026509"
15+
"sha": "84c8ad4e52f8eec8f08a60636cfa597b86969b5c",
16+
"internalRef": "255474859"
1717
}
1818
},
1919
{

0 commit comments

Comments
 (0)