13
13
# See the License for the specific language governing permissions and
14
14
# limitations under the License.
15
15
#
16
+ import logging as std_logging
16
17
from collections import OrderedDict
17
18
import re
18
19
from typing import (
54
55
from .transports .grpc_asyncio import DatastoreAdminGrpcAsyncIOTransport
55
56
from .client import DatastoreAdminClient
56
57
58
+ try :
59
+ from google .api_core import client_logging # type: ignore
60
+
61
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
62
+ except ImportError : # pragma: NO COVER
63
+ CLIENT_LOGGING_SUPPORTED = False
64
+
65
+ _LOGGER = std_logging .getLogger (__name__ )
66
+
57
67
58
68
class DatastoreAdminAsyncClient :
59
69
"""Google Cloud Datastore Admin API
@@ -311,6 +321,28 @@ def __init__(
311
321
client_info = client_info ,
312
322
)
313
323
324
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER .isEnabledFor (
325
+ std_logging .DEBUG
326
+ ): # pragma: NO COVER
327
+ _LOGGER .debug (
328
+ "Created client `google.datastore.admin_v1.DatastoreAdminAsyncClient`." ,
329
+ extra = {
330
+ "serviceName" : "google.datastore.admin.v1.DatastoreAdmin" ,
331
+ "universeDomain" : getattr (
332
+ self ._client ._transport ._credentials , "universe_domain" , ""
333
+ ),
334
+ "credentialsType" : f"{ type (self ._client ._transport ._credentials ).__module__ } .{ type (self ._client ._transport ._credentials ).__qualname__ } " ,
335
+ "credentialsInfo" : getattr (
336
+ self .transport ._credentials , "get_cred_info" , lambda : None
337
+ )(),
338
+ }
339
+ if hasattr (self ._client ._transport , "_credentials" )
340
+ else {
341
+ "serviceName" : "google.datastore.admin.v1.DatastoreAdmin" ,
342
+ "credentialsType" : None ,
343
+ },
344
+ )
345
+
314
346
async def export_entities (
315
347
self ,
316
348
request : Optional [Union [datastore_admin .ExportEntitiesRequest , dict ]] = None ,
@@ -321,7 +353,7 @@ async def export_entities(
321
353
output_url_prefix : Optional [str ] = None ,
322
354
retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
323
355
timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
324
- metadata : Sequence [Tuple [str , str ]] = (),
356
+ metadata : Sequence [Tuple [str , Union [ str , bytes ] ]] = (),
325
357
) -> operation_async .AsyncOperation :
326
358
r"""Exports a copy of all or a subset of entities from
327
359
Google Cloud Datastore to another storage system, such
@@ -420,8 +452,10 @@ async def sample_export_entities():
420
452
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
421
453
should be retried.
422
454
timeout (float): The timeout for this request.
423
- metadata (Sequence[Tuple[str, str]]): Strings which should be
424
- sent along with the request as metadata.
455
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
456
+ sent along with the request as metadata. Normally, each value must be of type `str`,
457
+ but for me
F438
tadata keys ending with the suffix `-bin`, the corresponding values must
458
+ be of type `bytes`.
425
459
426
460
Returns:
427
461
google.api_core.operation_async.AsyncOperation:
@@ -434,8 +468,9 @@ async def sample_export_entities():
434
468
# Create or coerce a protobuf request object.
435
469
# - Quick check: If we got a request object, we should *not* have
436
470
# gotten any keyword arguments that map to the request.
437
- has_flattened_params = any (
438
- [project_id , labels , entity_filter , output_url_prefix ]
471
+ flattened_params = [project_id , labels , entity_filter , output_url_prefix ]
472
+ has_flattened_params = (
473
+ len ([param for param in flattened_params if param is not None ]) > 0
439
474
)
440
475
if request is not None and has_flattened_params :
441
476
raise ValueError (
@@ -506,7 +541,7 @@ async def import_entities(
506
541
entity_filter : Optional [datastore_admin .EntityFilter ] = None ,
507
542
retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
508
543
timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
509
- metadata : Sequence [Tuple [str , str ]] = (),
544
+ metadata : Sequence [Tuple [str , Union [ str , bytes ] ]] = (),
510
545
) -> operation_async .AsyncOperation :
511
546
r"""Imports entities into Google Cloud Datastore.
512
547
Existing entities with the same key are overwritten. The
@@ -597,8 +632,10 @@ async def sample_import_entities():
597
632
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
598
633
should be retried.
599
634
timeout (float): The timeout for this request.
600
- metadata (Sequence[Tuple[str, str]]): Strings which should be
601
- sent along with the request as metadata.
635
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
636
+ sent along with the request as metadata. Normally, each value must be of type `str`,
637
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
638
+ be of type `bytes`.
602
639
603
640
Returns:
604
641
google.api_core.operation_async.AsyncOperation:
@@ -619,7 +656,10 @@ async def sample_import_entities():
619
656
# Create or coerce a protobuf request object.
620
657
# - Quick check: If we got a request object, we should *not* have
621
658
# gotten any keyword arguments that map to the request.
622
- has_flattened_params = any ([project_id , labels , input_url , entity_filter ])
659
+ flattened_params = [project_id , labels , input_url , entity_filter ]
660
+ has_flattened_params = (
661
+ len ([param for param in flattened_params if param is not None ]) > 0
662
+ )
623
663
if request is not None and has_flattened_params :
624
664
raise ValueError (
625
665
"If the `request` argument is set, then none of "
@@ -685,7 +725,7 @@ async def create_index(
685
725
* ,
686
726
retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
687
727
timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
688
- metadata : Sequence [Tuple [str , str ]] = (),
728
+ metadata : Sequence [Tuple [str , Union [ str , bytes ] ]] = (),
689
729
) -> operation_async .AsyncOperation :
690
730
r"""Creates the specified index. A newly created index's initial
691
731
state is ``CREATING``. On completion of the returned
@@ -739,8 +779,10 @@ async def sample_create_index():
739
779
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
740
780
should be retried.
741
781
timeout (float): The timeout for this request.
742
- metadata (Sequence[Tuple[str, str]]): Strings which should be
743
- sent along with the request as metadata.
782
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
783
+ sent along with the request as metadata. Normally, each value must be of type `str`,
784
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
785
+ be of type `bytes`.
744
786
745
787
Returns:
746
788
google.api_core.operation_async.AsyncOperation:
@@ -799,7 +841,7 @@ async def delete_index(
799
841
* ,
800
842
retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
801
843
timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
802
- metadata : Sequence [Tuple [str , str ]] = (),
844
+ metadata : Sequence [Tuple [str , Union [ str , bytes ] ]] = (),
803
845
) -> operation_async .AsyncOperation :
804
846
r"""Deletes an existing index. An index can only be deleted if it is
805
847
in a ``READY`` or ``ERROR`` state. On successful execution of
@@ -852,8 +894,10 @@ async def sample_delete_index():
852
894
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
853
895
should be retried.
854
896
timeout (float): The timeout for this request.
855
- metadata (Sequence[Tuple[str, str]]): Strings which should be
856
- sent along with the request as metadata.
897
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
898
+ sent along with the request as metadata. Normally, each value must be of type `str`,
899
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
900
+ be of type `bytes`.
857
901
858
902
Returns:
859
903
google.api_core.operation_async.AsyncOperation:
@@ -915,7 +959,7 @@ async def get_index(
915
959
* ,
916
960
retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
917
961
timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
918
- metadata : Sequence [Tuple [str , str ]] = (),
962
+ metadata : Sequence [Tuple [str , Union [ str , bytes ] ]] = (),
919
963
) -> index .Index :
920
964
r"""Gets an index.
921
965
@@ -951,8 +995,10 @@ async def sample_get_index():
951
995
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
952
996
should be retried.
953
997
timeout (float): The timeout for this request.
954
- metadata (Sequence[Tuple[str, str]]): Strings which should be
955
- sent along with the request as metadata.
998
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
999
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1000
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1001
+ be of type `bytes`.
956
1002
957
1003
Returns:
958
1004
google.cloud.datastore_admin_v1.types.Index:
@@ -1001,7 +1047,7 @@ async def list_indexes(
1001
1047
* ,
1002
1048
retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
1003
1049
timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
1004
- metadata : Sequence [Tuple [str , str ]] = (),
1050
+ metadata : Sequence [Tuple [str , Union [ str , bytes ] ]] = (),
1005
1051
) -> pagers .ListIndexesAsyncPager :
1006
1052
r"""Lists the indexes that match the specified filters.
1007
1053
Datastore uses an eventually consistent query to fetch
@@ -1041,8 +1087,10 @@ async def sample_list_indexes():
1041
1087
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
1042
1088
should be retried.
1043
1089
timeout (float): The timeout for this request.
1044
- metadata (Sequence[Tuple[str, str]]): Strings which should be
1045
- sent along with the request as metadata.
1090
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1091
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1092
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1093
+ be of type `bytes`.
1046
1094
1047
1095
Returns:
1048
1096
google.cloud.datastore_admin_v1.services.datastore_admin.pagers.ListIndexesAsyncPager:
@@ -1104,7 +1152,7 @@ async def list_operations(
1104
1152
* ,
1105
1153
retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
1106
1154
timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
1107
- metadata : Sequence [Tuple [str , str ]] = (),
1155
+ metadata : Sequence [Tuple [str , Union [ str , bytes ] ]] = (),
1108
1156
) -> operations_pb2 .ListOperationsResponse :
1109
1157
r"""Lists operations that match the specified filter in the request.
1110
1158
@@ -1115,8 +1163,10 @@ async def list_operations(
1115
1163
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
1116
1164
if any, should be retried.
1117
1165
timeout (float): The timeout for this request.
1118
- metadata (Sequence[Tuple[str, str]]): Strings which should be
1119
- sent along with the request as metadata.
1166
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1167
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1168
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1169
+ be of type `bytes`.
1120
1170
Returns:
1121
1171
~.operations_pb2.ListOperationsResponse:
1122
1172
Response message for ``ListOperations`` method.
@@ -1157,7 +1207,7 @@ async def get_operation(
1157
1207
* ,
1158
1208
retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
1159
1209
timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
1160
- metadata : Sequence [Tuple [str , str ]] = (),
1210
+ metadata : Sequence [Tuple [str , Union [ str , bytes ] ]] = (),
1161
1211
) -> operations_pb2 .Operation :
1162
1212
r"""Gets the latest state of a long-running operation.
1163
1213
@@ -1168,8 +1218,10 @@ async def get_operation(
1168
1218
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
1169
1219
if any, should be retried.
1170
1220
timeout (float): The timeout for this request.
1171
- metadata (Sequence[Tuple[str, str]]): Strings which should be
1172
- sent along with the request as metadata.
1221
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1222
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1223
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1224
+ be of type `bytes`.
1173
1225
Returns:
1174
1226
~.operations_pb2.Operation:
1175
1227
An ``Operation`` object.
@@ -1210,7 +1262,7 @@ async def delete_operation(
1210
1262
* ,
1211
1263
retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
1212
1264
timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
1213
- metadata : Sequence [Tuple [str , str ]] = (),
1265
+ metadata : Sequence [Tuple [str , Union [ str , bytes ] ]] = (),
1214
1266
) -> None :
1215
1267
r"""Deletes a long-running operation.
1216
1268
@@ -1226,8 +1278,10 @@ async def delete_operation(
1226
1278
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
1227
1279
if any, should be retried.
1228
1280
timeout (float): The timeout for this request.
1229
- metadata (Sequence[Tuple[str, str]]): Strings which should be
1230
- sent along with the request as metadata.
1281
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1282
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1283
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1284
+ be of type `bytes`.
1231
1285
Returns:
1232
1286
None
1233
1287
"""
@@ -1264,7 +1318,7 @@ async def cancel_operation(
1264
1318
* ,
1265
1319
retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
1266
1320
timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
1267
- metadata : Sequence [Tuple [str , str ]] = (),
1321
+ metadata : Sequence [Tuple [str , Union [ str , bytes ] ]] = (),
1268
1322
) -> None :
1269
1323
r"""Starts asynchronous cancellation on a long-running operation.
1270
1324
@@ -1279,8 +1333,10 @@ async def cancel_operation(
1279
1333
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
1280
1334
if any, should be retried.
1281
1335
timeout (float): The timeout for this request.
1282
- metadata (Sequence[Tuple[str, str]]): Strings which should be
1283
- sent along with the request as metadata.
1336
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1337
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1338
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1339
+ be of type `bytes`.
1284
1340
Returns:
1285
1341
None
1286
1342
"""
0 commit comments