1
1
# -*- coding: utf-8 -*-
2
- # Copyright 2023 Google LLC
2
+ # Copyright 2024 Google LLC
3
3
#
4
4
# Licensed under the Apache License, Version 2.0 (the "License");
5
5
# you may not use this file except in compliance with the License.
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 .api_core import operation # type: ignore
46
46
from google .api_core import operation_async # type: ignore
@@ -113,8 +113,12 @@ class DatastoreAdminAsyncClient:
113
113
114
114
_client : DatastoreAdminClient
115
115
116
+ # Copy defaults from the synchronous client for use here.
117
+ # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
116
118
DEFAULT_ENDPOINT = DatastoreAdminClient .DEFAULT_ENDPOINT
117
119
DEFAULT_MTLS_ENDPOINT = DatastoreAdminClient .DEFAULT_MTLS_ENDPOINT
120
+ _DEFAULT_ENDPOINT_TEMPLATE = DatastoreAdminClient ._DEFAULT_ENDPOINT_TEMPLATE
121
+ _DEFAULT_UNIVERSE = DatastoreAdminClient ._DEFAULT_UNIVERSE
118
122
119
123
common_billing_account_path = staticmethod (
120
124
DatastoreAdminClient .common_billing_account_path
@@ -219,6 +223,25 @@ def transport(self) -> DatastoreAdminTransport:
219
223
"""
220
224
return self ._client .transport
221
225
226
+ @property
227
+ def api_endpoint (self ):
228
+ """Return the API endpoint used by the client instance.
229
+
230
+ Returns:
231
+ str: The API endpoint used by the client instance.
232
+ """
233
+ return self ._client ._api_endpoint
234
+
235
+ @property
236
+ def universe_domain (self ) -> str :
237
+ """Return the universe domain used by the client instance.
238
+
239
+ Returns:
240
+ str: The universe domain used
241
+ by the client instance.
242
+ """
243
+ return self ._client ._universe_domain
244
+
222
245
get_transport_class = functools .partial (
223
246
type (DatastoreAdminClient ).get_transport_class , type (DatastoreAdminClient )
224
247
)
@@ -231,7 +254,7 @@ def __init__(
231
254
client_options : Optional [ClientOptions ] = None ,
232
255
client_info : gapic_v1 .client_info .ClientInfo = DEFAULT_CLIENT_INFO ,
233
256
) -> None :
234
- """Instantiates the datastore admin client.
257
+ """Instantiates the datastore admin async client.
235
258
236
259
Args:
237
260
credentials (Optional[google.auth.credentials.Credentials]): The
@@ -242,23 +265,38 @@ def __init__(
242
265
transport (Union[str, ~.DatastoreAdminTransport]): The
243
266
transport to use. If set to None, a transport is chosen
244
267
automatically.
245
- client_options (ClientOptions): Custom options for the client. It
246
- won't take effect if a ``transport`` instance is provided.
247
- (1) The ``api_endpoint`` property can be used to override the
248
- default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
249
- environment variable can also be used to override the endpoint:
268
+ client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
269
+ Custom options for the client.
270
+
271
+ 1. The ``api_endpoint`` property can be used to override the
272
+ default endpoint provided by the client when ``transport`` is
273
+ not explicitly provided. Only if this property is not set and
274
+ ``transport`` was not explicitly provided, the endpoint is
275
+ determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
276
+ variable, which have one of the following values:
250
277
"always" (always use the default mTLS endpoint), "never" (always
251
- use the default regular endpoint) and "auto" (auto switch to the
252
- default mTLS endpoint if client certificate is present, this is
253
- the default value). However, the ``api_endpoint`` property takes
254
- precedence if provided.
255
- (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
278
+ use the default regular endpoint) and "auto" (auto- switch to the
279
+ default mTLS endpoint if client certificate is present; this is
280
+ the default value).
281
+
282
+ 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
256
283
is "true", then the ``client_cert_source`` property can be used
257
- to provide client certificate for mutual TLS transport. If
284
+ to provide a client certificate for mTLS transport. If
258
285
not provided, the default SSL client certificate will be used if
259
286
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
260
287
set, no client certificate will be used.
261
288
289
+ 3. The ``universe_domain`` property can be used to override the
290
+ default "googleapis.com" universe. Note that ``api_endpoint``
291
+ property still takes precedence; and ``universe_domain`` is
292
+ currently not supported for mTLS.
293
+
294
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
295
+ The client info used to send a user-agent string along with
296
+ API requests. If ``None``, then default info will be used.
297
+ Generally, you only need to set this if you're developing
298
+ your own client library.
299
+
262
300
Raises:
263
301
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
264
302
creation failed for any reason.
@@ -432,6 +470,9 @@ async def sample_export_entities():
432
470
),
433
471
)
434
472
473
+ # Validate the universe domain.
474
+ self ._client ._validate_universe_domain ()
475
+
435
476
# Send the request.
436
477
response = await rpc (
437
478
request ,
@@ -611,6 +652,9 @@ async def sample_import_entities():
611
652
),
612
653
)
613
654
655
+ # Validate the universe domain.
656
+ self ._client ._validate_universe_domain ()
657
+
614
658
# Send the request.
615
659
response = await rpc (
616
660
request ,
@@ -721,6 +765,9 @@ async def sample_create_index():
721
765
),
722
766
)
723
767
768
+ # Validate the universe domain.
769
+ self ._client ._validate_universe_domain ()
770
+
724
771
# Send the request.
725
772
response = await rpc (
726
773
request ,
@@ -833,6 +880,9 @@ async def sample_delete_index():
833
880
),
834
881
)
835
882
883
+ # Validate the universe domain.
884
+ self ._client ._validate_universe_domain ()
885
+
836
886
# Send the request.
837
887
response = await rpc (
838
888
request ,
@@ -933,6 +983,9 @@ async def sample_get_index():
933
983
),
934
984
)
935
985
986
+ # Validate the universe domain.
987
+ self ._client ._validate_universe_domain ()
988
+
936
989
# Send the request.
937
990
response = await rpc (
938
991
request ,
@@ -1031,6 +1084,9 @@ async def sample_list_indexes():
1031
1084
),
1032
1085
)
1033
1086
1087
+ # Validate the universe domain.
1088
+ self ._client ._validate_universe_domain ()
1089
+
1034
1090
# Send the request.
1035
1091
response = await rpc (
1036
1092
request ,
@@ -1094,6 +1150,9 @@ async def list_operations(
1094
1150
gapic_v1 .routing_header .to_grpc_metadata ((("name" , request .name ),)),
1095
1151
)
1096
1152
1153
+ # Validate the universe domain.
1154
+ self ._client ._validate_universe_domain ()
1155
+
1097
1156
# Send the request.
1098
1157
response = await rpc (
1099
1158
request ,
@@ -1148,6 +1207,9 @@ async def get_operation(
1148
1207
gapic_v1 .routing_header .to_grpc_metadata ((("name" , request .name ),)),
1149
1208
)
1150
1209
1210
+ # Validate the universe domain.
1211
+ self ._client ._validate_universe_domain ()
1212
+
1151
1213
# Send the request.
1152
1214
response = await rpc (
1153
1215
request ,
@@ -1206,6 +1268,9 @@ async def delete_operation(
1206
1268
gapic_v1 .routing_header .to_grpc_metadata ((("name" , request .name ),)),
1207
1269
)
1208
1270
1271
+ # Validate the universe domain.
1272
+ self ._client ._validate_universe_domain ()
1273
+
1209
1274
# Send the request.
1210
1275
await rpc (
1211
1276
request ,
@@ -1260,6 +1325,9 @@ async def cancel_operation(
1260
1325
gapic_v1 .routing_header .to_grpc_metadata ((("name" , request .name ),)),
1261
1326
)
1262
1327
1328
+ # Validate the universe domain.
1329
+ self ._client ._validate_universe_domain ()
1330
+
1263
1331
# Send the request.
1264
1332
await rpc (
1265
1333
request ,
0 commit comments