Skip to content

Commit df9ceab

Browse files
yoshi-automationtseaver
authored andcommitted
Add 'client_options' support, update list method docstrings (via synth). (#8518)
1 parent b21def1 commit df9ceab

3 files changed

Lines changed: 53 additions & 23 deletions

File tree

google/cloud/pubsub_v1/gapic/publisher_client.py

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

2626
from google.oauth2 import service_account
27+
import google.api_core.client_options
2728
import google.api_core.gapic_v1.client_info
2829
import google.api_core.gapic_v1.config
2930
import google.api_core.gapic_v1.method
@@ -130,6 +131,7 @@ def __init__(
130131
credentials=None,
131132
client_config=None,
132133
client_info=None,
134+
client_options=None,
133135
):
134136
"""Constructor.
135137
@@ -160,6 +162,9 @@ def __init__(
160162
API requests. If ``None``, then default info will be used.
161163
Generally, you only need to set this if you're developing
162164
your own client library.
165+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
166+
Client options used to set user options on the client. API Endpoint
167+
should be set through client_options.
163168
"""
164169
default_client_config = deepcopy(publisher_client_config.config)
165170

@@ -175,6 +180,15 @@ def __init__(
175180
stacklevel=2,
176181
)
177182

183+
api_endpoint = self.SERVICE_ADDRESS
184+
if client_options:
185+
if type(client_options) == dict:
186+
client_options = google.api_core.client_options.from_dict(
187+
client_options
188+
)
189+
if client_options.api_endpoint:
190+
api_endpoint = client_options.api_endpoint
191+
178192
# Instantiate the transport.
179193
# The transport is responsible for handling serialization and
180194
# deserialization and actually sending data to the service.
@@ -183,6 +197,7 @@ def __init__(
183197
self.transport = transport(
184198
credentials=credentials,
185199
default_class=publisher_grpc_transport.PublisherGrpcTransport,
200+
address=api_endpoint,
186201
)
187202
else:
188203
if credentials:
@@ -193,7 +208,7 @@ def __init__(
193208
self.transport = transport
194209
else:
195210
self.transport = publisher_grpc_transport.PublisherGrpcTransport(
196-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
211+
address=api_endpoint, channel=channel, credentials=credentials
197212
)
198213

199214
if client_info is None:
@@ -607,10 +622,10 @@ def list_topics(
607622
that is provided to the method.
608623
609624
Returns:
610-
A :class:`~google.gax.PageIterator` instance. By default, this
611-
is an iterable of :class:`~google.cloud.pubsub_v1.types.Topic` instances.
612-
This object can also be configured to iterate over the pages
613-
of the response through the `options` parameter.
625+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
626+
An iterable of :class:`~google.cloud.pubsub_v1.types.Topic` instances.
627+
You can also iterate over the pages of the response
628+
using its `pages` property.
614629
615630
Raises:
616631
google.api_core.exceptions.GoogleAPICallError: If the request
@@ -709,10 +724,10 @@ def list_topic_subscriptions(
709724
that is provided to the method.
710725
711726
Returns:
712-
A :class:`~google.gax.PageIterator` instance. By default, this
713-
is an iterable of :class:`str` instances.
714-
This object can also be configured to iterate over the pages
715-
of the response through the `options` parameter.
727+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
728+
An iterable of :class:`str` instances.
729+
You can also iterate over the pages of the response
730+
using its `pages` property.
716731
717732
Raises:
718733
google.api_core.exceptions.GoogleAPICallError: If the request

google/cloud/pubsub_v1/gapic/subscriber_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
@@ -126,6 +127,7 @@ def __init__(
126127
credentials=None,
127128
client_config=None,
128129
client_info=None,
130+
client_options=None,
129131
):
130132
"""Constructor.
131133
@@ -156,6 +158,9 @@ def __init__(
156158
API requests. If ``None``, then default info will be used.
157159
Generally, you only need to set this if you're developing
158160
your own client library.
161+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
162+
Client options used to set user options on the client. API Endpoint
163+
should be set through client_options.
159164
"""
160165
# Raise deprecation warnings for things we want to go away.
161166
if client_config is not None:
@@ -174,6 +179,15 @@ def __init__(
174179
stacklevel=2,
175180
)
176181

182+
api_endpoint = self.SERVICE_ADDRESS
183+
if client_options:
184+
if type(client_options) == dict:
185+
client_options = google.api_core.client_options.from_dict(
186+
client_options
187+
)
188+
if client_options.api_endpoint:
189+
api_endpoint = client_options.api_endpoint
190+
177191
# Instantiate the transport.
178192
# The transport is responsible for handling serialization and
179193
# deserialization and actually sending data to the service.
@@ -182,6 +196,7 @@ def __init__(
182196
self.transport = transport(
183197
credentials=credentials,
184198
default_class=subscriber_grpc_transport.SubscriberGrpcTransport,
199+
address=api_endpoint,
185200
)
186201
else:
187202
if credentials:
@@ -192,7 +207,7 @@ def __init__(
192207
self.transport = transport
193208
else:
194209
self.transport = subscriber_grpc_transport.SubscriberGrpcTransport(
195-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
210+
address=api_endpoint, channel=channel, credentials=credentials
196211
)
197212

198213
if client_info is None:
@@ -586,10 +601,10 @@ def list_subscriptions(
586601
that is provided to the method.
587602
588603
Returns:
589-
A :class:`~google.gax.PageIterator` instance. By default, this
590-
is an iterable of :class:`~google.cloud.pubsub_v1.types.Subscription` instances.
591-
This object can also be configured to iterate over the pages
592-
of the response through the `options` parameter.
604+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
605+
An iterable of :class:`~google.cloud.pubsub_v1.types.Subscription` instances.
606+
You can also iterate over the pages of the response
607+
using its `pages` property.
593608
594609
Raises:
595610
google.api_core.exceptions.GoogleAPICallError: If the request
@@ -1185,10 +1200,10 @@ def list_snapshots(
11851200
that is provided to the method.
11861201
11871202
Returns:
1188-
A :class:`~google.gax.PageIterator` instance. By default, this
1189-
is an iterable of :class:`~google.cloud.pubsub_v1.types.Snapshot` instances.
1190-
This object can also be configured to iterate over the pages
1191-
of the response through the `options` parameter.
1203+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
1204+
An iterable of :class:`~google.cloud.pubsub_v1.types.Snapshot` instances.
1205+
You can also iterate over the pages of the response
1206+
using its `pages` property.
11921207
11931208
Raises:
11941209
google.api_core.exceptions.GoogleAPICallError: If the request

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-20T16:24:11.087131Z",
2+
"updateTime": "2019-06-28T12:30:21.076185Z",
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)