1313# See the License for the specific language governing permissions and
1414# limitations under the License.
1515#
16+ import logging as std_logging
1617from collections import OrderedDict
1718import re
1819from typing import (
5455from .transports .grpc_asyncio import DatastoreAdminGrpcAsyncIOTransport
5556from .client import DatastoreAdminClient
5657
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+
5767
5868class DatastoreAdminAsyncClient :
5969 """Google Cloud Datastore Admin API
@@ -311,6 +321,28 @@ def __init__(
311321 client_info = client_info ,
312322 )
313323
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+
314346 async def export_entities (
315347 self ,
316348 request : Optional [Union [datastore_admin .ExportEntitiesRequest , dict ]] = None ,
@@ -321,7 +353,7 @@ async def export_entities(
321353 output_url_prefix : Optional [str ] = None ,
322354 retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
323355 timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
324- metadata : Sequence [Tuple [str , str ]] = (),
356+ metadata : Sequence [Tuple [str , Union [ str , bytes ] ]] = (),
325357 ) -> operation_async .AsyncOperation :
326358 r"""Exports a copy of all or a subset of entities from
327359 Google Cloud Datastore to another storage system, such
@@ -420,8 +452,10 @@ async def sample_export_entities():
420452 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
421453 should be retried.
422454 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 metadata keys ending with the suffix `-bin`, the corresponding values must
458+ be of type `bytes`.
425459
426460 Returns:
427461 google.api_core.operation_async.AsyncOperation:
@@ -434,8 +468,9 @@ async def sample_export_entities():
434468 # Create or coerce a protobuf request object.
435469 # - Quick check: If we got a request object, we should *not* have
436470 # 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
439474 )
440475 if request is not None and has_flattened_params :
441476 raise ValueError (
@@ -506,7 +541,7 @@ async def import_entities(
506541 entity_filter : Optional [datastore_admin .EntityFilter ] = None ,
507542 retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
508543 timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
509- metadata : Sequence [Tuple [str , str ]] = (),
544+ metadata : Sequence [Tuple [str , Union [ str , bytes ] ]] = (),
510545 ) -> operation_async .AsyncOperation :
511546 r"""Imports entities into Google Cloud Datastore.
512547 Existing entities with the same key are overwritten. The
@@ -597,8 +632,10 @@ async def sample_import_entities():
597632 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
598633 should be retried.
599634 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`.
602639
603640 Returns:
604641 google.api_core.operation_async.AsyncOperation:
@@ -619,7 +656,10 @@ async def sample_import_entities():
619656 # Create or coerce a protobuf request object.
620657 # - Quick check: If we got a request object, we should *not* have
621658 # 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+ )
623663 if request is not None and has_flattened_params :
624664 raise ValueError (
625665 "If the `request` argument is set, then none of "
@@ -685,7 +725,7 @@ async def create_index(
685725 * ,
686726 retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
687727 timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
688- metadata : Sequence [Tuple [str , str ]] = (),
728+ metadata : Sequence [Tuple [str , Union [ str , bytes ] ]] = (),
689729 ) -> operation_async .AsyncOperation :
690730 r"""Creates the specified index. A newly created index's initial
691731 state is ``CREATING``. On completion of the returned
@@ -739,8 +779,10 @@ async def sample_create_index():
739779 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
740780 should be retried.
741781 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`.
744786
745787 Returns:
746788 google.api_core.operation_async.AsyncOperation:
@@ -799,7 +841,7 @@ async def delete_index(
799841 * ,
800842 retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
801843 timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
802- metadata : Sequence [Tuple [str , str ]] = (),
844+ metadata : Sequence [Tuple [str , Union [ str , bytes ] ]] = (),
803845 ) -> operation_async .AsyncOperation :
804846 r"""Deletes an existing index. An index can only be deleted if it is
805847 in a ``READY`` or ``ERROR`` state. On successful execution of
@@ -852,8 +894,10 @@ async def sample_delete_index():
852894 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
853895 should be retried.
854896 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`.
857901
858902 Returns:
859903 google.api_core.operation_async.AsyncOperation:
@@ -915,7 +959,7 @@ async def get_index(
915959 * ,
916960 retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
917961 timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
918- metadata : Sequence [Tuple [str , str ]] = (),
962+ metadata : Sequence [Tuple [str , Union [ str , bytes ] ]] = (),
919963 ) -> index .Index :
920964 r"""Gets an index.
921965
@@ -951,8 +995,10 @@ async def sample_get_index():
951995 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
952996 should be retried.
953997 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`.
9561002
9571003 Returns:
9581004 google.cloud.datastore_admin_v1.types.Index:
@@ -1001,7 +1047,7 @@ async def list_indexes(
10011047 * ,
10021048 retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
10031049 timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
1004- metadata : Sequence [Tuple [str , str ]] = (),
1050+ metadata : Sequence [Tuple [str , Union [ str , bytes ] ]] = (),
10051051 ) -> pagers .ListIndexesAsyncPager :
10061052 r"""Lists the indexes that match the specified filters.
10071053 Datastore uses an eventually consistent query to fetch
@@ -1041,8 +1087,10 @@ async def sample_list_indexes():
10411087 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
10421088 should be retried.
10431089 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`.
10461094
10471095 Returns:
10481096 google.cloud.datastore_admin_v1.services.datastore_admin.pagers.ListIndexesAsyncPager:
@@ -1104,7 +1152,7 @@ async def list_operations(
11041152 * ,
11051153 retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
11061154 timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
1107- metadata : Sequence [Tuple [str , str ]] = (),
1155+ metadata : Sequence [Tuple [str , Union [ str , bytes ] ]] = (),
11081156 ) -> operations_pb2 .ListOperationsResponse :
11091157 r"""Lists operations that match the specified filter in the request.
11101158
@@ -1115,8 +1163,10 @@ async def list_operations(
11151163 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
11161164 if any, should be retried.
11171165 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`.
11201170 Returns:
11211171 ~.operations_pb2.ListOperationsResponse:
11221172 Response message for ``ListOperations`` method.
@@ -1157,7 +1207,7 @@ async def get_operation(
11571207 * ,
11581208 retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
11591209 timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
1160- metadata : Sequence [Tuple [str , str ]] = (),
1210+ metadata : Sequence [Tuple [str , Union [ str , bytes ] ]] = (),
11611211 ) -> operations_pb2 .Operation :
11621212 r"""Gets the latest state of a long-running operation.
11631213
@@ -1168,8 +1218,10 @@ async def get_operation(
11681218 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
11691219 if any, should be retried.
11701220 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`.
11731225 Returns:
11741226 ~.operations_pb2.Operation:
11751227 An ``Operation`` object.
@@ -1210,7 +1262,7 @@ async def delete_operation(
12101262 * ,
12111263 retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
12121264 timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
1213- metadata : Sequence [Tuple [str , str ]] = (),
1265+ metadata : Sequence [Tuple [str , Union [ str , bytes ] ]] = (),
12141266 ) -> None :
12151267 r"""Deletes a long-running operation.
12161268
@@ -1226,8 +1278,10 @@ async def delete_operation(
12261278 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
12271279 if any, should be retried.
12281280 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`.
12311285 Returns:
12321286 None
12331287 """
@@ -1264,7 +1318,7 @@ async def cancel_operation(
12641318 * ,
12651319 retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
12661320 timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
1267- metadata : Sequence [Tuple [str , str ]] = (),
1321+ metadata : Sequence [Tuple [str , Union [ str , bytes ] ]] = (),
12681322 ) -> None :
12691323 r"""Starts asynchronous cancellation on a long-running operation.
12701324
@@ -1279,8 +1333,10 @@ async def cancel_operation(
12791333 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
12801334 if any, should be retried.
12811335 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`.
12841340 Returns:
12851341 None
12861342 """
0 commit comments