@@ -287,11 +287,18 @@ async def export_entities(
287
287
288
288
.. code-block:: python
289
289
290
+ # This snippet has been automatically generated and should be regarded as a
291
+ # code template only.
292
+ # It will require modifications to work:
293
+ # - It may require correct/in-range values for request initialization.
294
+ # - It may require specifying regional endpoints when creating the service
295
+ # client as shown in:
296
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
290
297
from google.cloud import datastore_admin_v1
291
298
292
- def sample_export_entities():
299
+ async def sample_export_entities():
293
300
# Create a client
294
- client = datastore_admin_v1.DatastoreAdminClient ()
301
+ client = datastore_admin_v1.DatastoreAdminAsyncClient ()
295
302
296
303
# Initialize request argument(s)
297
304
request = datastore_admin_v1.ExportEntitiesRequest(
@@ -304,7 +311,7 @@ def sample_export_entities():
304
311
305
312
print("Waiting for operation to complete...")
306
313
307
- response = operation.result()
314
+ response = await operation.result()
308
315
309
316
# Handle the response
310
317
print(response)
@@ -409,6 +416,14 @@ def sample_export_entities():
409
416
client_info = DEFAULT_CLIENT_INFO ,
410
417
)
411
418
419
+ # Certain fields should be provided within the metadata header;
420
+ # add these here.
421
+ metadata = tuple (metadata ) + (
422
+ gapic_v1 .routing_header .to_grpc_metadata (
423
+ (("project_id" , request .project_id ),)
424
+ ),
425
+ )
426
+
412
427
# Send the request.
413
428
response = await rpc (
414
429
request ,
@@ -450,11 +465,18 @@ async def import_entities(
450
465
451
466
.. code-block:: python
452
467
468
+ # This snippet has been automatically generated and should be regarded as a
469
+ # code template only.
470
+ # It will require modifications to work:
471
+ # - It may require correct/in-range values for request initialization.
472
+ # - It may require specifying regional endpoints when creating the service
473
+ # client as shown in:
474
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
453
475
from google.cloud import datastore_admin_v1
454
476
455
- def sample_import_entities():
477
+ async def sample_import_entities():
456
478
# Create a client
457
- client = datastore_admin_v1.DatastoreAdminClient ()
479
+ client = datastore_admin_v1.DatastoreAdminAsyncClient ()
458
480
459
481
# Initialize request argument(s)
460
482
request = datastore_admin_v1.ImportEntitiesRequest(
@@ -467,7 +489,7 @@ def sample_import_entities():
467
489
468
490
print("Waiting for operation to complete...")
469
491
470
- response = operation.result()
492
+ response = await operation.result()
471
493
472
494
# Handle the response
473
495
print(response)
@@ -540,9 +562,6 @@ def sample_import_entities():
540
562
541
563
}
542
564
543
- The JSON representation for Empty is empty JSON
544
- object {}.
545
-
546
565
"""
547
566
# Create or coerce a protobuf request object.
548
567
# Quick check: If we got a request object, we should *not* have
@@ -576,6 +595,14 @@ def sample_import_entities():
576
595
client_info = DEFAULT_CLIENT_INFO ,
577
596
)
578
597
598
+ # Certain fields should be provided within the metadata header;
599
+ # add these here.
600
+ metadata = tuple (metadata ) + (
601
+ gapic_v1 .routing_header .to_grpc_metadata (
602
+ (("project_id" , request .project_id ),)
603
+ ),
604
+ )
605
+
579
606
# Send the request.
580
607
response = await rpc (
581
608
request ,
@@ -621,11 +648,18 @@ async def create_index(
621
648
622
649
.. code-block:: python
623
650
651
+ # This snippet has been automatically generated and should be regarded as a
652
+ # code template only.
653
+ # It will require modifications to work:
654
+ # - It may require correct/in-range values for request initialization.
655
+ # - It may require specifying regional endpoints when creating the service
656
+ # client as shown in:
657
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
624
658
from google.cloud import datastore_admin_v1
625
659
626
- def sample_create_index():
660
+ async def sample_create_index():
627
661
# Create a client
628
- client = datastore_admin_v1.DatastoreAdminClient ()
662
+ client = datastore_admin_v1.DatastoreAdminAsyncClient ()
629
663
630
664
# Initialize request argument(s)
631
665
request = datastore_admin_v1.CreateIndexRequest(
@@ -636,7 +670,7 @@ def sample_create_index():
636
670
637
671
print("Waiting for operation to complete...")
638
672
639
- response = operation.result()
673
+ response = await operation.result()
640
674
641
675
# Handle the response
642
676
print(response)
@@ -671,6 +705,14 @@ def sample_create_index():
671
705
client_info = DEFAULT_CLIENT_INFO ,
672
706
)
673
707
708
+ # Certain fields should be provided within the metadata header;
709
+ # add these here.
710
+ metadata = tuple (metadata ) + (
711
+ gapic_v1 .routing_header .to_grpc_metadata (
712
+ (("project_id" , request .project_id ),)
713
+ ),
714
+ )
715
+
674
716
# Send the request.
675
717
response = await rpc (
676
718
request ,
@@ -715,11 +757,18 @@ async def delete_index(
715
757
716
758
.. code-block:: python
717
759
760
+ # This snippet has been automatically generated and should be regarded as a
761
+ # code template only.
762
+ # It will require modifications to work:
763
+ # - It may require correct/in-range values for request initialization.
764
+ # - It may require specifying regional endpoints when creating the service
765
+ # client as shown in:
766
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
718
767
from google.cloud import datastore_admin_v1
719
768
720
- def sample_delete_index():
769
+ async def sample_delete_index():
721
770
# Create a client
722
- client = datastore_admin_v1.DatastoreAdminClient ()
771
+ client = datastore_admin_v1.DatastoreAdminAsyncClient ()
723
772
724
773
# Initialize request argument(s)
725
774
request = datastore_admin_v1.DeleteIndexRequest(
@@ -730,7 +779,7 @@ def sample_delete_index():
730
779
731
780
print("Waiting for operation to complete...")
732
781
733
- response = operation.result()
782
+ response = await operation.result()
734
783
735
784
# Handle the response
736
785
print(response)
@@ -765,6 +814,17 @@ def sample_delete_index():
765
814
client_info = DEFAULT_CLIENT_INFO ,
766
815
)
767
816
817
+ # Certain fields should be provided within the metadata header;
818
+ # add these here.
819
+ metadata = tuple (metadata ) + (
820
+ gapic_v1 .routing_header .to_grpc_metadata (
821
+ (
822
+ ("project_id" , request .project_id ),
823
+ ("index_id" , request .index_id ),
824
+ )
825
+ ),
826
+ )
827
+
768
828
# Send the request.
769
829
response = await rpc (
770
830
request ,
@@ -796,18 +856,25 @@ async def get_index(
796
856
797
857
.. code-block:: python
798
858
859
+ # This snippet has been automatically generated and should be regarded as a
860
+ # code template only.
861
+ # It will require modifications to work:
862
+ # - It may require correct/in-range values for request initialization.
863
+ # - It may require specifying regional endpoints when creating the service
864
+ # client as shown in:
865
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
799
866
from google.cloud import datastore_admin_v1
800
867
801
- def sample_get_index():
868
+ async def sample_get_index():
802
869
# Create a client
803
- client = datastore_admin_v1.DatastoreAdminClient ()
870
+ client = datastore_admin_v1.DatastoreAdminAsyncClient ()
804
871
805
872
# Initialize request argument(s)
806
873
request = datastore_admin_v1.GetIndexRequest(
807
874
)
808
875
809
876
# Make the request
810
- response = client.get_index(request=request)
877
+ response = await client.get_index(request=request)
811
878
812
879
# Handle the response
813
880
print(response)
@@ -847,6 +914,17 @@ def sample_get_index():
847
914
client_info = DEFAULT_CLIENT_INFO ,
848
915
)
849
916
917
+ # Certain fields should be provided within the metadata header;
918
+ # add these here.
919
+ metadata = tuple (metadata ) + (
920
+ gapic_v1 .routing_header .to_grpc_metadata (
921
+ (
922
+ ("project_id" , request .project_id ),
923
+ ("index_id" , request .index_id ),
924
+ )
925
+ ),
926
+ )
927
+
850
928
# Send the request.
851
929
response = await rpc (
852
930
request ,
@@ -873,11 +951,18 @@ async def list_indexes(
873
951
874
952
.. code-block:: python
875
953
954
+ # This snippet has been automatically generated and should be regarded as a
955
+ # code template only.
956
+ # It will require modifications to work:
957
+ # - It may require correct/in-range values for request initialization.
958
+ # - It may require specifying regional endpoints when creating the service
959
+ # client as shown in:
960
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
876
961
from google.cloud import datastore_admin_v1
877
962
878
- def sample_list_indexes():
963
+ async def sample_list_indexes():
879
964
# Create a client
880
- client = datastore_admin_v1.DatastoreAdminClient ()
965
+ client = datastore_admin_v1.DatastoreAdminAsyncClient ()
881
966
882
967
# Initialize request argument(s)
883
968
request = datastore_admin_v1.ListIndexesRequest(
@@ -887,7 +972,7 @@ def sample_list_indexes():
887
972
page_result = client.list_indexes(request=request)
888
973
889
974
# Handle the response
890
- for response in page_result:
975
+ async for response in page_result:
891
976
print(response)
892
977
893
978
Args:
@@ -930,6 +1015,14 @@ def sample_list_indexes():
930
1015
client_info = DEFAULT_CLIENT_INFO ,
931
1016
)
932
1017
1018
+ # Certain fields should be provided within the metadata header;
1019
+ # add these here.
1020
+ metadata = tuple (metadata ) + (
1021
+ gapic_v1 .routing_header .to_grpc_metadata (
1022
+ (("project_id" , request .project_id ),)
1023
+ ),
1024
+ )
1025
+
933
1026
# Send the request.
934
1027
response = await rpc (
935
1028
request ,
0 commit comments