google-cloud-firestore 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,6 @@
4
4
  "retry_codes": {
5
5
  "idempotent": [
6
6
  "DEADLINE_EXCEEDED",
7
- "INTERNAL",
8
7
  "UNAVAILABLE"
9
8
  ],
10
9
  "non_idempotent": []
@@ -21,6 +20,16 @@
21
20
  }
22
21
  },
23
22
  "methods": {
23
+ "DeleteIndex": {
24
+ "timeout_millis": 60000,
25
+ "retry_codes_name": "idempotent",
26
+ "retry_params_name": "default"
27
+ },
28
+ "UpdateField": {
29
+ "timeout_millis": 60000,
30
+ "retry_codes_name": "non_idempotent",
31
+ "retry_params_name": "default"
32
+ },
24
33
  "CreateIndex": {
25
34
  "timeout_millis": 60000,
26
35
  "retry_codes_name": "non_idempotent",
@@ -36,14 +45,14 @@
36
45
  "retry_codes_name": "idempotent",
37
46
  "retry_params_name": "default"
38
47
  },
39
- "DeleteIndex": {
48
+ "GetField": {
40
49
  "timeout_millis": 60000,
41
50
  "retry_codes_name": "idempotent",
42
51
  "retry_params_name": "default"
43
52
  },
44
- "ImportDocuments": {
53
+ "ListFields": {
45
54
  "timeout_millis": 60000,
46
- "retry_codes_name": "non_idempotent",
55
+ "retry_codes_name": "idempotent",
47
56
  "retry_params_name": "default"
48
57
  },
49
58
  "ExportDocuments": {
@@ -51,17 +60,7 @@
51
60
  "retry_codes_name": "non_idempotent",
52
61
  "retry_params_name": "default"
53
62
  },
54
- "GetField": {
55
- "timeout_millis": 60000,
56
- "retry_codes_name": "idempotent",
57
- "retry_params_name": "default"
58
- },
59
- "ListFields": {
60
- "timeout_millis": 60000,
61
- "retry_codes_name": "idempotent",
62
- "retry_params_name": "default"
63
- },
64
- "UpdateField": {
63
+ "ImportDocuments": {
65
64
  "timeout_millis": 60000,
66
65
  "retry_codes_name": "non_idempotent",
67
66
  "retry_params_name": "default"
@@ -71,7 +71,10 @@ module Google
71
71
  end
72
72
 
73
73
  def get_documents document_paths, mask: nil, transaction: nil
74
- batch_get_args = { mask: document_mask(mask) }
74
+ batch_get_args = {
75
+ documents: document_paths,
76
+ mask: document_mask(mask)
77
+ }
75
78
  if transaction.is_a? String
76
79
  batch_get_args[:transaction] = transaction
77
80
  elsif transaction
@@ -80,8 +83,7 @@ module Google
80
83
  batch_get_args[:options] = call_options parent: database_path
81
84
 
82
85
  execute do
83
- firestore.batch_get_documents database_path, document_paths,
84
- batch_get_args
86
+ firestore.batch_get_documents database_path, **batch_get_args
85
87
  end
86
88
  end
87
89
 
@@ -115,7 +117,7 @@ module Google
115
117
  list_args[:options] = call_options parent: database_path
116
118
 
117
119
  execute do
118
- firestore.list_collection_ids parent, list_args
120
+ firestore.list_collection_ids parent, **list_args
119
121
  end
120
122
  end
121
123
 
@@ -129,7 +131,7 @@ module Google
129
131
  run_query_args[:options] = call_options parent: database_path
130
132
 
131
133
  execute do
132
- firestore.run_query path, run_query_args
134
+ firestore.run_query path, **run_query_args
133
135
  end
134
136
  end
135
137
 
@@ -152,12 +154,14 @@ module Google
152
154
  end
153
155
 
154
156
  def commit writes, transaction: nil
155
- commit_args = {}
157
+ commit_args = {
158
+ writes: writes
159
+ }
156
160
  commit_args[:transaction] = transaction if transaction
157
161
  commit_args[:options] = call_options parent: database_path
158
162
 
159
163
  execute do
160
- firestore.commit database_path, writes, commit_args
164
+ firestore.commit database_path, **commit_args
161
165
  end
162
166
  end
163
167
 
@@ -170,11 +174,13 @@ module Google
170
174
  end
171
175
 
172
176
  def database_path project_id: project, database_id: "(default)"
173
- V1::FirestoreClient.database_root_path project_id, database_id
177
+ # Originally used V1::FirestoreClient.database_root_path until it was removed in #5405.
178
+ "projects/#{project_id}/databases/#{database_id}"
174
179
  end
175
180
 
176
181
  def documents_path project_id: project, database_id: "(default)"
177
- V1::FirestoreClient.document_root_path project_id, database_id
182
+ # Originally used V1::FirestoreClient.document_root_path until it was removed in #5405.
183
+ "projects/#{project_id}/databases/#{database_id}/documents"
178
184
  end
179
185
 
180
186
  def inspect
@@ -80,80 +80,6 @@ module Google
80
80
  ].freeze
81
81
 
82
82
 
83
- ANY_PATH_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
84
- "projects/{project}/databases/{database}/documents/{document}/{any_path=**}"
85
- )
86
-
87
- private_constant :ANY_PATH_PATH_TEMPLATE
88
-
89
- DATABASE_ROOT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
90
- "projects/{project}/databases/{database}"
91
- )
92
-
93
- private_constant :DATABASE_ROOT_PATH_TEMPLATE
94
-
95
- DOCUMENT_PATH_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
96
- "projects/{project}/databases/{database}/documents/{document_path=**}"
97
- )
98
-
99
- private_constant :DOCUMENT_PATH_PATH_TEMPLATE
100
-
101
- DOCUMENT_ROOT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
102
- "projects/{project}/databases/{database}/documents"
103
- )
104
-
105
- private_constant :DOCUMENT_ROOT_PATH_TEMPLATE
106
-
107
- # Returns a fully-qualified any_path resource name string.
108
- # @param project [String]
109
- # @param database [String]
110
- # @param document [String]
111
- # @param any_path [String]
112
- # @return [String]
113
- def self.any_path_path project, database, document, any_path
114
- ANY_PATH_PATH_TEMPLATE.render(
115
- :"project" => project,
116
- :"database" => database,
117
- :"document" => document,
118
- :"any_path" => any_path
119
- )
120
- end
121
-
122
- # Returns a fully-qualified database_root resource name string.
123
- # @param project [String]
124
- # @param database [String]
125
- # @return [String]
126
- def self.database_root_path project, database
127
- DATABASE_ROOT_PATH_TEMPLATE.render(
128
- :"project" => project,
129
- :"database" => database
130
- )
131
- end
132
-
133
- # Returns a fully-qualified document_path resource name string.
134
- # @param project [String]
135
- # @param database [String]
136
- # @param document_path [String]
137
- # @return [String]
138
- def self.document_path_path project, database, document_path
139
- DOCUMENT_PATH_PATH_TEMPLATE.render(
140
- :"project" => project,
141
- :"database" => database,
142
- :"document_path" => document_path
143
- )
144
- end
145
-
146
- # Returns a fully-qualified document_root resource name string.
147
- # @param project [String]
148
- # @param database [String]
149
- # @return [String]
150
- def self.document_root_path project, database
151
- DOCUMENT_ROOT_PATH_TEMPLATE.render(
152
- :"project" => project,
153
- :"database" => database
154
- )
155
- end
156
-
157
83
  # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
158
84
  # Provides the means for authenticating requests made by the client. This parameter can
159
85
  # be many types.
@@ -393,8 +319,10 @@ module Google
393
319
  # require "google/cloud/firestore/v1"
394
320
  #
395
321
  # firestore_client = Google::Cloud::Firestore::V1.new
396
- # formatted_name = Google::Cloud::Firestore::V1::FirestoreClient.any_path_path("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]")
397
- # response = firestore_client.get_document(formatted_name)
322
+ #
323
+ # # TODO: Initialize `name`:
324
+ # name = ''
325
+ # response = firestore_client.get_document(name)
398
326
 
399
327
  def get_document \
400
328
  name,
@@ -471,18 +399,20 @@ module Google
471
399
  # require "google/cloud/firestore/v1"
472
400
  #
473
401
  # firestore_client = Google::Cloud::Firestore::V1.new
474
- # formatted_parent = Google::Cloud::Firestore::V1::FirestoreClient.any_path_path("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]")
402
+ #
403
+ # # TODO: Initialize `parent`:
404
+ # parent = ''
475
405
  #
476
406
  # # TODO: Initialize `collection_id`:
477
407
  # collection_id = ''
478
408
  #
479
409
  # # Iterate over all results.
480
- # firestore_client.list_documents(formatted_parent, collection_id).each do |element|
410
+ # firestore_client.list_documents(parent, collection_id).each do |element|
481
411
  # # Process element.
482
412
  # end
483
413
  #
484
414
  # # Or iterate over results one page at a time.
485
- # firestore_client.list_documents(formatted_parent, collection_id).each_page do |page|
415
+ # firestore_client.list_documents(parent, collection_id).each_page do |page|
486
416
  # # Process each page at a time.
487
417
  # page.each do |element|
488
418
  # # Process element.
@@ -522,14 +452,14 @@ module Google
522
452
  # `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}`
523
453
  # @param collection_id [String]
524
454
  # Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`.
525
- # @param document_id [String]
526
- # The client-assigned document ID to use for this document.
527
- #
528
- # Optional. If not specified, an ID will be assigned by the service.
529
455
  # @param document [Google::Firestore::V1::Document | Hash]
530
456
  # Required. The document to create. `name` must not be set.
531
457
  # A hash of the same form as `Google::Firestore::V1::Document`
532
458
  # can also be provided.
459
+ # @param document_id [String]
460
+ # The client-assigned document ID to use for this document.
461
+ #
462
+ # Optional. If not specified, an ID will be assigned by the service.
533
463
  # @param mask [Google::Firestore::V1::DocumentMask | Hash]
534
464
  # The fields to return. If not set, returns all fields.
535
465
  #
@@ -549,31 +479,30 @@ module Google
549
479
  # require "google/cloud/firestore/v1"
550
480
  #
551
481
  # firestore_client = Google::Cloud::Firestore::V1.new
552
- # formatted_parent = Google::Cloud::Firestore::V1::FirestoreClient.any_path_path("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]")
482
+ #
483
+ # # TODO: Initialize `parent`:
484
+ # parent = ''
553
485
  #
554
486
  # # TODO: Initialize `collection_id`:
555
487
  # collection_id = ''
556
488
  #
557
- # # TODO: Initialize `document_id`:
558
- # document_id = ''
559
- #
560
489
  # # TODO: Initialize `document`:
561
490
  # document = {}
562
- # response = firestore_client.create_document(formatted_parent, collection_id, document_id, document)
491
+ # response = firestore_client.create_document(parent, collection_id, document)
563
492
 
564
493
  def create_document \
565
494
  parent,
566
495
  collection_id,
567
- document_id,
568
496
  document,
497
+ document_id: nil,
569
498
  mask: nil,
570
499
  options: nil,
571
500
  &block
572
501
  req = {
573
502
  parent: parent,
574
503
  collection_id: collection_id,
575
- document_id: document_id,
576
504
  document: document,
505
+ document_id: document_id,
577
506
  mask: mask
578
507
  }.delete_if { |_, v| v.nil? }
579
508
  req = Google::Gax::to_proto(req, Google::Firestore::V1::CreateDocumentRequest)
@@ -624,14 +553,11 @@ module Google
624
553
  #
625
554
  # # TODO: Initialize `document`:
626
555
  # document = {}
627
- #
628
- # # TODO: Initialize `update_mask`:
629
- # update_mask = {}
630
- # response = firestore_client.update_document(document, update_mask)
556
+ # response = firestore_client.update_document(document)
631
557
 
632
558
  def update_document \
633
559
  document,
634
- update_mask,
560
+ update_mask: nil,
635
561
  mask: nil,
636
562
  current_document: nil,
637
563
  options: nil,
@@ -667,8 +593,10 @@ module Google
667
593
  # require "google/cloud/firestore/v1"
668
594
  #
669
595
  # firestore_client = Google::Cloud::Firestore::V1.new
670
- # formatted_name = Google::Cloud::Firestore::V1::FirestoreClient.any_path_path("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]")
671
- # firestore_client.delete_document(formatted_name)
596
+ #
597
+ # # TODO: Initialize `name`:
598
+ # name = ''
599
+ # firestore_client.delete_document(name)
672
600
 
673
601
  def delete_document \
674
602
  name,
@@ -729,17 +657,16 @@ module Google
729
657
  # require "google/cloud/firestore/v1"
730
658
  #
731
659
  # firestore_client = Google::Cloud::Firestore::V1.new
732
- # formatted_database = Google::Cloud::Firestore::V1::FirestoreClient.database_root_path("[PROJECT]", "[DATABASE]")
733
660
  #
734
- # # TODO: Initialize `documents`:
735
- # documents = []
736
- # firestore_client.batch_get_documents(formatted_database, documents).each do |element|
661
+ # # TODO: Initialize `database`:
662
+ # database = ''
663
+ # firestore_client.batch_get_documents(database).each do |element|
737
664
  # # Process element.
738
665
  # end
739
666
 
740
667
  def batch_get_documents \
741
668
  database,
742
- documents,
669
+ documents: nil,
743
670
  mask: nil,
744
671
  transaction: nil,
745
672
  new_transaction: nil,
@@ -779,8 +706,10 @@ module Google
779
706
  # require "google/cloud/firestore/v1"
780
707
  #
781
708
  # firestore_client = Google::Cloud::Firestore::V1.new
782
- # formatted_database = Google::Cloud::Firestore::V1::FirestoreClient.database_root_path("[PROJECT]", "[DATABASE]")
783
- # response = firestore_client.begin_transaction(formatted_database)
709
+ #
710
+ # # TODO: Initialize `database`:
711
+ # database = ''
712
+ # response = firestore_client.begin_transaction(database)
784
713
 
785
714
  def begin_transaction \
786
715
  database,
@@ -820,15 +749,14 @@ module Google
820
749
  # require "google/cloud/firestore/v1"
821
750
  #
822
751
  # firestore_client = Google::Cloud::Firestore::V1.new
823
- # formatted_database = Google::Cloud::Firestore::V1::FirestoreClient.database_root_path("[PROJECT]", "[DATABASE]")
824
752
  #
825
- # # TODO: Initialize `writes`:
826
- # writes = []
827
- # response = firestore_client.commit(formatted_database, writes)
753
+ # # TODO: Initialize `database`:
754
+ # database = ''
755
+ # response = firestore_client.commit(database)
828
756
 
829
757
  def commit \
830
758
  database,
831
- writes,
759
+ writes: nil,
832
760
  transaction: nil,
833
761
  options: nil,
834
762
  &block
@@ -859,11 +787,13 @@ module Google
859
787
  # require "google/cloud/firestore/v1"
860
788
  #
861
789
  # firestore_client = Google::Cloud::Firestore::V1.new
862
- # formatted_database = Google::Cloud::Firestore::V1::FirestoreClient.database_root_path("[PROJECT]", "[DATABASE]")
790
+ #
791
+ # # TODO: Initialize `database`:
792
+ # database = ''
863
793
  #
864
794
  # # TODO: Initialize `transaction`:
865
795
  # transaction = ''
866
- # firestore_client.rollback(formatted_database, transaction)
796
+ # firestore_client.rollback(database, transaction)
867
797
 
868
798
  def rollback \
869
799
  database,
@@ -917,8 +847,10 @@ module Google
917
847
  # require "google/cloud/firestore/v1"
918
848
  #
919
849
  # firestore_client = Google::Cloud::Firestore::V1.new
920
- # formatted_parent = Google::Cloud::Firestore::V1::FirestoreClient.any_path_path("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]")
921
- # firestore_client.run_query(formatted_parent).each do |element|
850
+ #
851
+ # # TODO: Initialize `parent`:
852
+ # parent = ''
853
+ # firestore_client.run_query(parent).each do |element|
922
854
  # # Process element.
923
855
  # end
924
856
 
@@ -961,8 +893,10 @@ module Google
961
893
  # require "google/cloud/firestore/v1"
962
894
  #
963
895
  # firestore_client = Google::Cloud::Firestore::V1.new
964
- # formatted_database = Google::Cloud::Firestore::V1::FirestoreClient.database_root_path("[PROJECT]", "[DATABASE]")
965
- # request = { database: formatted_database }
896
+ #
897
+ # # TODO: Initialize `database`:
898
+ # database = ''
899
+ # request = { database: database }
966
900
  # requests = [request]
967
901
  # firestore_client.write(requests).each do |element|
968
902
  # # Process element.
@@ -996,8 +930,10 @@ module Google
996
930
  # require "google/cloud/firestore/v1"
997
931
  #
998
932
  # firestore_client = Google::Cloud::Firestore::V1.new
999
- # formatted_database = Google::Cloud::Firestore::V1::FirestoreClient.database_root_path("[PROJECT]", "[DATABASE]")
1000
- # request = { database: formatted_database }
933
+ #
934
+ # # TODO: Initialize `database`:
935
+ # database = ''
936
+ # request = { database: database }
1001
937
  # requests = [request]
1002
938
  # firestore_client.listen(requests).each do |element|
1003
939
  # # Process element.
@@ -1039,15 +975,17 @@ module Google
1039
975
  # require "google/cloud/firestore/v1"
1040
976
  #
1041
977
  # firestore_client = Google::Cloud::Firestore::V1.new
1042
- # formatted_parent = Google::Cloud::Firestore::V1::FirestoreClient.any_path_path("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]")
978
+ #
979
+ # # TODO: Initialize `parent`:
980
+ # parent = ''
1043
981
  #
1044
982
  # # Iterate over all results.
1045
- # firestore_client.list_collection_ids(formatted_parent).each do |element|
983
+ # firestore_client.list_collection_ids(parent).each do |element|
1046
984
  # # Process element.
1047
985
  # end
1048
986
  #
1049
987
  # # Or iterate over results one page at a time.
1050
- # firestore_client.list_collection_ids(formatted_parent).each_page do |page|
988
+ # firestore_client.list_collection_ids(parent).each_page do |page|
1051
989
  # # Process each page at a time.
1052
990
  # page.each do |element|
1053
991
  # # Process element.