Skip to content

Commit 68bcf18

Browse files
yoshi-automationtseaver
authored andcommitted
Add 'client_options' support, update list method docstrings (via synth). (#8519)
1 parent 74fb4fc commit 68bcf18

3 files changed

Lines changed: 45 additions & 15 deletions

File tree

redis/google/cloud/redis_v1/gapic/cloud_redis_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
@@ -123,6 +124,7 @@ def __init__(
123124
credentials=None,
124125
client_config=None,
125126
client_info=None,
127+
client_options=None,
126128
):
127129
"""Constructor.
128130
@@ -153,6 +155,9 @@ def __init__(
153155
API requests. If ``None``, then default info will be used.
154156
Generally, you only need to set this if you're developing
155157
your own client library.
158+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
159+
Client options used to set user options on the client. API Endpoint
160+
should be set through client_options.
156161
"""
157162
# Raise deprecation warnings for things we want to go away.
158163
if client_config is not None:
@@ -171,6 +176,15 @@ def __init__(
171176
stacklevel=2,
172177
)
173178

179+
api_endpoint = self.SERVICE_ADDRESS
180+
if client_options:
181+
if type(client_options) == dict:
182+
client_options = google.api_core.client_options.from_dict(
183+
client_options
184+
)
185+
if client_options.api_endpoint:
186+
api_endpoint = client_options.api_endpoint
187+
174188
# Instantiate the transport.
175189
# The transport is responsible for handling serialization and
176190
# deserialization and actually sending data to the service.
@@ -179,6 +193,7 @@ def __init__(
179193
self.transport = transport(
180194
credentials=credentials,
181195
default_class=cloud_redis_grpc_transport.CloudRedisGrpcTransport,
196+
address=api_endpoint,
182197
)
183198
else:
184199
if credentials:
@@ -189,7 +204,7 @@ def __init__(
189204
self.transport = transport
190205
else:
191206
self.transport = cloud_redis_grpc_transport.CloudRedisGrpcTransport(
192-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
207+
address=api_endpoint, channel=channel, credentials=credentials
193208
)
194209

195210
if client_info is None:
@@ -274,10 +289,10 @@ def list_instances(
274289
that is provided to the method.
275290
276291
Returns:
277-
A :class:`~google.gax.PageIterator` instance. By default, this
278-
is an iterable of :class:`~google.cloud.redis_v1.types.Instance` instances.
279-
This object can also be configured to iterate over the pages
280-
of the response through the `options` parameter.
292+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
293+
An iterable of :class:`~google.cloud.redis_v1.types.Instance` instances.
294+
You can also iterate over the pages of the response
295+
using its `pages` property.
281296
282297
Raises:
283298
google.api_core.exceptions.GoogleAPICallError: If the request

redis/google/cloud/redis_v1beta1/gapic/cloud_redis_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
@@ -124,6 +125,7 @@ def __init__(
124125
credentials=None,
125126
client_config=None,
126127
client_info=None,
128+
client_options=None,
127129
):
128130
"""Constructor.
129131
@@ -154,6 +156,9 @@ def __init__(
154156
API requests. If ``None``, then default info will be used.
155157
Generally, you only need to set this if you're developing
156158
your own client library.
159+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
160+
Client options used to set user options on the client. API Endpoint
161+
should be set through client_options.
157162
"""
158163
# Raise deprecation warnings for things we want to go away.
159164
if client_config is not None:
@@ -172,6 +177,15 @@ def __init__(
172177
stacklevel=2,
173178
)
174179

180+
api_endpoint = self.SERVICE_ADDRESS
181+
if client_options:
182+
if type(client_options) == dict:
183+
client_options = google.api_core.client_options.from_dict(
184+
client_options
185+
)
186+
if client_options.api_endpoint:
187+
api_endpoint = client_options.api_endpoint
188+
175189
# Instantiate the transport.
176190
# The transport is responsible for handling serialization and
177191
# deserialization and actually sending data to the service.
@@ -180,6 +194,7 @@ def __init__(
180194
self.transport = transport(
181195
credentials=credentials,
182196
default_class=cloud_redis_grpc_transport.CloudRedisGrpcTransport,
197+
address=api_endpoint,
183198
)
184199
else:
185200
if credentials:
@@ -190,7 +205,7 @@ def __init__(
190205
self.transport = transport
191206
else:
192207
self.transport = cloud_redis_grpc_transport.CloudRedisGrpcTransport(
193-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
208+
address=api_endpoint, channel=channel, credentials=credentials
194209
)
195210

196211
if client_info is None:
@@ -275,10 +290,10 @@ def list_instances(
275290
that is provided to the method.
276291
277292
Returns:
278-
A :class:`~google.gax.PageIterator` instance. By default, this
279-
is an iterable of :class:`~google.cloud.redis_v1beta1.types.Instance` instances.
280-
This object can also be configured to iterate over the pages
281-
of the response through the `options` parameter.
293+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
294+
An iterable of :class:`~google.cloud.redis_v1beta1.types.Instance` instances.
295+
You can also iterate over the pages of the response
296+
using its `pages` property.
282297
283298
Raises:
284299
google.api_core.exceptions.GoogleAPICallError: If the request

redis/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:25:06.486345Z",
2+
"updateTime": "2019-06-28T12:31:12.709692Z",
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)