38
38
from google .oauth2 import service_account # type: ignore
39
39
40
40
try :
41
- OptionalRetry = Union [retries .AsyncRetry , gapic_v1 .method ._MethodDefault ]
41
+ OptionalRetry = Union [retries .AsyncRetry , gapic_v1 .method ._MethodDefault , None ]
42
42
except AttributeError : # pragma: NO COVER
43
- OptionalRetry = Union [retries .AsyncRetry , object ] # type: ignore
43
+ OptionalRetry = Union [retries .AsyncRetry , object , None ] # type: ignore
44
44
45
45
from google .iam .v1 import iam_policy_pb2 # type: ignore
46
46
from google .iam .v1 import policy_pb2 # type: ignore
@@ -61,8 +61,12 @@ class PublisherAsyncClient:
61
61
62
62
_client : PublisherClient
63
63
64
+ # Copy defaults from the synchronous client for use here.
65
+ # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
64
66
DEFAULT_ENDPOINT = PublisherClient .DEFAULT_ENDPOINT
65
67
DEFAULT_MTLS_ENDPOINT = PublisherClient .DEFAULT_MTLS_ENDPOINT
68
+ _DEFAULT_ENDPOINT_TEMPLATE = PublisherClient ._DEFAULT_ENDPOINT_TEMPLATE
69
+ _DEFAULT_UNIVERSE = PublisherClient ._DEFAULT_UNIVERSE
66
70
67
71
schema_path = staticmethod (PublisherClient .schema_path )
68
72
parse_schema_path = staticmethod (PublisherClient .parse_schema_path )
@@ -167,6 +171,25 @@ def transport(self) -> PublisherTransport:
167
171
"""
168
172
return self ._client .transport
169
173
174
+ @property
175
+ def api_endpoint (self ):
176
+ """Return the API endpoint used by the client instance.
177
+
178
+ Returns:
179
+ str: The API endpoint used by the client instance.
180
+ """
181
+ return self ._client ._api_endpoint
182
+
183
+ @property
184
+ def universe_domain (self ) -> str :
185
+ """Return the universe domain used by the client instance.
186
+
187
+ Returns:
188
+ str: The universe domain used
189
+ by the client instance.
190
+ """
191
+ return self ._client ._universe_domain
192
+
170
193
get_transport_class = functools .partial (
171
194
type (PublisherClient ).get_transport_class , type (PublisherClient )
172
195
)
@@ -179,7 +202,7 @@ def __init__(
179
202
client_options : Optional [ClientOptions ] = None ,
180
203
client_info : gapic_v1 .client_info .ClientInfo = DEFAULT_CLIENT_INFO ,
181
204
) -> None :
182
- """Instantiates the publisher client.
205
+ """Instantiates the publisher async client.
183
206
184
207
Args:
185
208
credentials (Optional[google.auth.credentials.Credentials]): The
@@ -190,23 +213,38 @@ def __init__(
190
213
transport (Union[str, ~.PublisherTransport]): The
191
214
transport to use. If set to None, a transport is chosen
192
215
automatically.
193
- client_options (ClientOptions): Custom options for the client. It
194
- won't take effect if a ``transport`` instance is provided.
195
- (1) The ``api_endpoint`` property can be used to override the
196
- default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
197
- environment variable can also be used to override the endpoint:
216
+ client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
217
+ Custom options for the client.
218
+
219
+ 1. The ``api_endpoint`` property can be used to override the
220
+ default endpoint provided by the client when ``transport`` is
221
+ not explicitly provided. Only if this property is not set and
222
+ ``transport`` was not explicitly provided, the endpoint is
223
+ determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
224
+ variable, which have one of the following values:
198
225
"always" (always use the default mTLS endpoint), "never" (always
199
- use the default regular endpoint) and "auto" (auto switch to the
200
- default mTLS endpoint if client certificate is present, this is
201
- the default value). However, the ``api_endpoint`` property takes
202
- precedence if provided.
203
- (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
226
+ use the default regular endpoint) and "auto" (auto- switch to the
227
+ default mTLS endpoint if client certificate is present; this is
228
+ the default value).
229
+
230
+ 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
204
231
is "true", then the ``client_cert_source`` property can be used
205
- to provide client certificate for mutual TLS transport. If
232
+ to provide a client certificate for mTLS transport. If
206
233
not provided, the default SSL client certificate will be used if
207
234
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
208
235
set, no client certificate will be used.
209
236
237
+ 3. The ``universe_domain`` property can be used to override the
238
+ default "googleapis.com" universe. Note that ``api_endpoint``
239
+ property still takes precedence; and ``universe_domain`` is
240
+ currently not supported for mTLS.
241
+
242
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
243
+ The client info used to send a user-agent string along with
244
+ API requests. If ``None``, then default info will be used.
245
+ Generally, you only need to set this if you're developing
246
+ your own client library.
247
+
210
248
Raises:
211
249
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
212
250
creation failed for any reason.
@@ -324,6 +362,9 @@ async def sample_create_topic():
324
362
gapic_v1 .routing_header .to_grpc_metadata ((("name" , request .name ),)),
325
363
)
326
364
365
+ # Validate the universe domain.
366
+ self ._client ._validate_universe_domain ()
367
+
327
368
# Send the request.
328
369
response = await rpc (
329
370
request ,
@@ -345,7 +386,8 @@ async def update_topic(
345
386
timeout : TimeoutType = gapic_v1 .method .DEFAULT ,
346
387
metadata : Sequence [Tuple [str , str ]] = (),
347
388
) -> pubsub .Topic :
348
- r"""Updates an existing topic. Note that certain
389
+ r"""Updates an existing topic by updating the fields
390
+ specified in the update mask. Note that certain
349
391
properties of a topic are not modifiable.
350
392
351
393
.. code-block:: python
@@ -452,6 +494,9 @@ async def sample_update_topic():
452
494
),
453
495
)
454
496
497
+ # Validate the universe domain.
498
+ self ._client ._validate_universe_domain ()
499
+
455
500
# Send the request.
456
501
response = await rpc (
457
502
request ,
@@ -555,7 +600,7 @@ async def sample_publish():
555
600
default_retry = retries .AsyncRetry (
556
601
initial = 0.1 ,
557
602
maximum = 60.0 ,
558
- multiplier = 4.0 ,
603
+ multiplier = 4 ,
559
604
predicate = retries .if_exception_type (
560
605
core_exceptions .Aborted ,
561
606
core_exceptions .Cancelled ,
@@ -577,6 +622,9 @@ async def sample_publish():
577
622
gapic_v1 .routing_header .to_grpc_metadata ((("topic" , request .topic ),)),
578
623
)
579
624
625
+ # Validate the universe domain.
626
+ self ._client ._validate_universe_domain ()
627
+
580
628
# Send the request.
581
629
response = await rpc (
582
630
request ,
@@ -688,6 +736,9 @@ async def sample_get_topic():
688
736
gapic_v1 .routing_header .to_grpc_metadata ((("topic" , request .topic ),)),
689
737
)
690
738
739
+ # Validate the universe domain.
740
+ self ._client ._validate_universe_domain ()
741
+
691
742
# Send the request.
692
743
response = await rpc (
693
744
request ,
@@ -804,6 +855,9 @@ async def sample_list_topics():
804
855
gapic_v1 .routing_header .to_grpc_metadata ((("project" , request .project ),)),
805
856
)
806
857
858
+ # Validate the universe domain.
859
+ self ._client ._validate_universe_domain ()
860
+
807
861
# Send the request.
808
862
response = await rpc (
809
863
request ,
@@ -931,6 +985,9 @@ async def sample_list_topic_subscriptions():
931
985
gapic_v1 .routing_header .to_grpc_metadata ((("topic" , request .topic ),)),
932
986
)
933
987
988
+ # Validate the universe domain.
989
+ self ._client ._validate_universe_domain ()
990
+
934
991
# Send the request.
935
992
response = await rpc (
936
993
request ,
@@ -1062,6 +1119,9 @@ async def sample_list_topic_snapshots():
1062
1119
gapic_v1 .routing_header .to_grpc_metadata ((("topic" , request .topic ),)),
1063
1120
)
1064
1121
1122
+ # Validate the universe domain.
1123
+ self ._client ._validate_universe_domain ()
1124
+
1065
1125
# Send the request.
1066
1126
response = await rpc (
1067
1127
request ,
@@ -1178,6 +1238,9 @@ async def sample_delete_topic():
1178
1238
gapic_v1 .routing_header .to_grpc_metadata ((("topic" , request .topic ),)),
1179
1239
)
1180
1240
1241
+ # Validate the universe domain.
1242
+ self ._client ._validate_universe_domain ()
1243
+
1181
1244
# Send the request.
1182
1245
await rpc (
1183
1246
request ,
@@ -1271,6 +1334,9 @@ async def sample_detach_subscription():
1271
1334
),
1272
1335
)
1273
1336
1337
+ # Validate the universe domain.
1338
+ self ._client ._validate_universe_domain ()
1339
+
1274
1340
# Send the request.
1275
1341
response = await rpc (
1276
1342
request ,
@@ -1391,6 +1457,9 @@ async def set_iam_policy(
1391
1457
gapic_v1 .routing_header .to_grpc_metadata ((("resource" , request .resource ),)),
1392
1458
)
1393
1459
1460
+ # Validate the universe domain.
1461
+ self ._client ._validate_universe_domain ()
1462
+
1394
1463
# Send the request.
1395
1464
response = await rpc (
1396
1465
request ,
@@ -1513,6 +1582,9 @@ async def get_iam_policy(
1513
1582
gapic_v1 .routing_header .to_grpc_metadata ((("resource" , request .resource ),)),
1514
1583
)
1515
1584
1585
+ # Validate the universe domain.
1586
+ self ._client ._validate_universe_domain ()
1587
+
1516
1588
# Send the request.
1517
1589
response = await rpc (
1518
1590
request ,
@@ -1573,6 +1645,9 @@ async def test_iam_permissions(
1573
1645
gapic_v1 .routing_header .to_grpc_metadata ((("resource" , request .resource ),)),
1574
1646
)
1575
1647
1648
+ # Validate the universe domain.
1649
+ self ._client ._validate_universe_domain ()
1650
+
1576
1651
# Send the request.
1577
1652
response = await rpc (
1578
1653
request ,
0 commit comments