3838from google .oauth2 import service_account # type: ignore
3939
4040try :
41- OptionalRetry = Union [retries .AsyncRetry , gapic_v1 .method ._MethodDefault ]
41+ OptionalRetry = Union [retries .AsyncRetry , gapic_v1 .method ._MethodDefault , None ]
4242except AttributeError : # pragma: NO COVER
43- OptionalRetry = Union [retries .AsyncRetry , object ] # type: ignore
43+ OptionalRetry = Union [retries .AsyncRetry , object , None ] # type: ignore
4444
4545from google .iam .v1 import iam_policy_pb2 # type: ignore
4646from google .iam .v1 import policy_pb2 # type: ignore
@@ -61,8 +61,12 @@ class PublisherAsyncClient:
6161
6262 _client : PublisherClient
6363
64+ # Copy defaults from the synchronous client for use here.
65+ # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
6466 DEFAULT_ENDPOINT = PublisherClient .DEFAULT_ENDPOINT
6567 DEFAULT_MTLS_ENDPOINT = PublisherClient .DEFAULT_MTLS_ENDPOINT
68+ _DEFAULT_ENDPOINT_TEMPLATE = PublisherClient ._DEFAULT_ENDPOINT_TEMPLATE
69+ _DEFAULT_UNIVERSE = PublisherClient ._DEFAULT_UNIVERSE
6670
6771 schema_path = staticmethod (PublisherClient .schema_path )
6872 parse_schema_path = staticmethod (PublisherClient .parse_schema_path )
@@ -167,6 +171,25 @@ def transport(self) -> PublisherTransport:
167171 """
168172 return self ._client .transport
169173
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+
170193 get_transport_class = functools .partial (
171194 type (PublisherClient ).get_transport_class , type (PublisherClient )
172195 )
@@ -179,7 +202,7 @@ def __init__(
179202 client_options : Optional [ClientOptions ] = None ,
180203 client_info : gapic_v1 .client_info .ClientInfo = DEFAULT_CLIENT_INFO ,
181204 ) -> None :
182- """Instantiates the publisher client.
205+ """Instantiates the publisher async client.
183206
184207 Args:
185208 credentials (Optional[google.auth.credentials.Credentials]): The
@@ -190,23 +213,38 @@ def __init__(
190213 transport (Union[str, ~.PublisherTransport]): The
191214 transport to use. If set to None, a transport is chosen
192215 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:
198225 "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
204231 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
206233 not provided, the default SSL client certificate will be used if
207234 present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
208235 set, no client certificate will be used.
209236
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+
210248 Raises:
211249 google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
212250 creation failed for any reason.
@@ -324,6 +362,9 @@ async def sample_create_topic():
324362 gapic_v1 .routing_header .to_grpc_metadata ((("name" , request .name ),)),
325363 )
326364
365+ # Validate the universe domain.
366+ self ._client ._validate_universe_domain ()
367+
327368 # Send the request.
328369 response = await rpc (
329370 request ,
@@ -345,7 +386,8 @@ async def update_topic(
345386 timeout : TimeoutType = gapic_v1 .method .DEFAULT ,
346387 metadata : Sequence [Tuple [str , str ]] = (),
347388 ) -> 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
349391 properties of a topic are not modifiable.
350392
351393 .. code-block:: python
@@ -452,6 +494,9 @@ async def sample_update_topic():
452494 ),
453495 )
454496
497+ # Validate the universe domain.
498+ self ._client ._validate_universe_domain ()
499+
455500 # Send the request.
456501 response = await rpc (
457502 request ,
@@ -555,7 +600,7 @@ async def sample_publish():
555600 default_retry = retries .AsyncRetry (
556601 initial = 0.1 ,
557602 maximum = 60.0 ,
558- multiplier = 4.0 ,
603+ multiplier = 4 ,
559604 predicate = retries .if_exception_type (
560605 core_exceptions .Aborted ,
561606 core_exceptions .Cancelled ,
@@ -577,6 +622,9 @@ async def sample_publish():
577622 gapic_v1 .routing_header .to_grpc_metadata ((("topic" , request .topic ),)),
578623 )
579624
625+ # Validate the universe domain.
626+ self ._client ._validate_universe_domain ()
627+
580628 # Send the request.
581629 response = await rpc (
582630 request ,
@@ -688,6 +736,9 @@ async def sample_get_topic():
688736 gapic_v1 .routing_header .to_grpc_metadata ((("topic" , request .topic ),)),
689737 )
690738
739+ # Validate the universe domain.
740+ self ._client ._validate_universe_domain ()
741+
691742 # Send the request.
692743 response = await rpc (
693744 request ,
@@ -804,6 +855,9 @@ async def sample_list_topics():
804855 gapic_v1 .routing_header .to_grpc_metadata ((("project" , request .project ),)),
805856 )
806857
858+ # Validate the universe domain.
859+ self ._client ._validate_universe_domain ()
860+
807861 # Send the request.
808862 response = await rpc (
809863 request ,
@@ -931,6 +985,9 @@ async def sample_list_topic_subscriptions():
931985 gapic_v1 .routing_header .to_grpc_metadata ((("topic" , request .topic ),)),
932986 )
933987
988+ # Validate the universe domain.
989+ self ._client ._validate_universe_domain ()
990+
934991 # Send the request.
935992 response = await rpc (
936993 request ,
@@ -1062,6 +1119,9 @@ async def sample_list_topic_snapshots():
10621119 gapic_v1 .routing_header .to_grpc_metadata ((("topic" , request .topic ),)),
10631120 )
10641121
1122+ # Validate the universe domain.
1123+ self ._client ._validate_universe_domain ()
1124+
10651125 # Send the request.
10661126 response = await rpc (
10671127 request ,
@@ -1178,6 +1238,9 @@ async def sample_delete_topic():
11781238 gapic_v1 .routing_header .to_grpc_metadata ((("topic" , request .topic ),)),
11791239 )
11801240
1241+ # Validate the universe domain.
1242+ self ._client ._validate_universe_domain ()
1243+
11811244 # Send the request.
11821245 await rpc (
11831246 request ,
@@ -1271,6 +1334,9 @@ async def sample_detach_subscription():
12711334 ),
12721335 )
12731336
1337+ # Validate the universe domain.
1338+ self ._client ._validate_universe_domain ()
1339+
12741340 # Send the request.
12751341 response = await rpc (
12761342 request ,
@@ -1391,6 +1457,9 @@ async def set_iam_policy(
13911457 gapic_v1 .routing_header .to_grpc_metadata ((("resource" , request .resource ),)),
13921458 )
13931459
1460+ # Validate the universe domain.
1461+ self ._client ._validate_universe_domain ()
1462+
13941463 # Send the request.
13951464 response = await rpc (
13961465 request ,
@@ -1513,6 +1582,9 @@ async def get_iam_policy(
15131582 gapic_v1 .routing_header .to_grpc_metadata ((("resource" , request .resource ),)),
15141583 )
15151584
1585+ # Validate the universe domain.
1586+ self ._client ._validate_universe_domain ()
1587+
15161588 # Send the request.
15171589 response = await rpc (
15181590 request ,
@@ -1573,6 +1645,9 @@ async def test_iam_permissions(
15731645 gapic_v1 .routing_header .to_grpc_metadata ((("resource" , request .resource ),)),
15741646 )
15751647
1648+ # Validate the universe domain.
1649+ self ._client ._validate_universe_domain ()
1650+
15761651 # Send the request.
15771652 response = await rpc (
15781653 request ,
0 commit comments