google-cloud-firestore-v1 0.4.2 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -46,13 +46,12 @@ module Google
46
46
  # See {::Google::Cloud::Firestore::V1::Firestore::Client::Configuration}
47
47
  # for a description of the configuration fields.
48
48
  #
49
- # ## Example
49
+ # @example
50
50
  #
51
- # To modify the configuration for all Firestore clients:
52
- #
53
- # ::Google::Cloud::Firestore::V1::Firestore::Client.configure do |config|
54
- # config.timeout = 10.0
55
- # end
51
+ # # Modify the configuration for all Firestore clients
52
+ # ::Google::Cloud::Firestore::V1::Firestore::Client.configure do |config|
53
+ # config.timeout = 10.0
54
+ # end
56
55
  #
57
56
  # @yield [config] Configure the Client client.
58
57
  # @yieldparam config [Client::Configuration]
@@ -72,116 +71,74 @@ module Google
72
71
 
73
72
  default_config.rpcs.get_document.timeout = 60.0
74
73
  default_config.rpcs.get_document.retry_policy = {
75
- initial_delay: 0.1,
76
- max_delay: 60.0,
77
- multiplier: 1.3,
78
- retry_codes: [8, 14, 13, 4]
74
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4]
79
75
  }
80
76
 
81
77
  default_config.rpcs.list_documents.timeout = 60.0
82
78
  default_config.rpcs.list_documents.retry_policy = {
83
- initial_delay: 0.1,
84
- max_delay: 60.0,
85
- multiplier: 1.3,
86
- retry_codes: [8, 14, 13, 4]
79
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4]
87
80
  }
88
81
 
89
82
  default_config.rpcs.update_document.timeout = 60.0
90
83
  default_config.rpcs.update_document.retry_policy = {
91
- initial_delay: 0.1,
92
- max_delay: 60.0,
93
- multiplier: 1.3,
94
- retry_codes: [8, 14]
84
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14]
95
85
  }
96
86
 
97
87
  default_config.rpcs.delete_document.timeout = 60.0
98
88
  default_config.rpcs.delete_document.retry_policy = {
99
- initial_delay: 0.1,
100
- max_delay: 60.0,
101
- multiplier: 1.3,
102
- retry_codes: [8, 14, 13, 4]
89
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4]
103
90
  }
104
91
 
105
92
  default_config.rpcs.batch_get_documents.timeout = 300.0
106
93
  default_config.rpcs.batch_get_documents.retry_policy = {
107
- initial_delay: 0.1,
108
- max_delay: 60.0,
109
- multiplier: 1.3,
110
- retry_codes: [8, 14, 13, 4]
94
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4]
111
95
  }
112
96
 
113
97
  default_config.rpcs.begin_transaction.timeout = 60.0
114
98
  default_config.rpcs.begin_transaction.retry_policy = {
115
- initial_delay: 0.1,
116
- max_delay: 60.0,
117
- multiplier: 1.3,
118
- retry_codes: [8, 14, 13, 4]
99
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4]
119
100
  }
120
101
 
121
102
  default_config.rpcs.commit.timeout = 60.0
122
103
  default_config.rpcs.commit.retry_policy = {
123
- initial_delay: 0.1,
124
- max_delay: 60.0,
125
- multiplier: 1.3,
126
- retry_codes: [8, 14]
104
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14]
127
105
  }
128
106
 
129
107
  default_config.rpcs.rollback.timeout = 60.0
130
108
  default_config.rpcs.rollback.retry_policy = {
131
- initial_delay: 0.1,
132
- max_delay: 60.0,
133
- multiplier: 1.3,
134
- retry_codes: [8, 14, 13, 4]
109
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4]
135
110
  }
136
111
 
137
112
  default_config.rpcs.run_query.timeout = 300.0
138
113
  default_config.rpcs.run_query.retry_policy = {
139
- initial_delay: 0.1,
140
- max_delay: 60.0,
141
- multiplier: 1.3,
142
- retry_codes: [8, 14, 13, 4]
114
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4]
143
115
  }
144
116
 
145
117
  default_config.rpcs.partition_query.timeout = 300.0
146
118
  default_config.rpcs.partition_query.retry_policy = {
147
- initial_delay: 0.1,
148
- max_delay: 60.0,
149
- multiplier: 1.3,
150
- retry_codes: [8, 14, 13, 4]
119
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4]
151
120
  }
152
121
 
153
122
  default_config.rpcs.write.timeout = 86_400.0
154
123
 
155
124
  default_config.rpcs.listen.timeout = 86_400.0
156
125
  default_config.rpcs.listen.retry_policy = {
157
- initial_delay: 0.1,
158
- max_delay: 60.0,
159
- multiplier: 1.3,
160
- retry_codes: [8, 14, 13, 4]
126
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4]
161
127
  }
162
128
 
163
129
  default_config.rpcs.list_collection_ids.timeout = 60.0
164
130
  default_config.rpcs.list_collection_ids.retry_policy = {
165
- initial_delay: 0.1,
166
- max_delay: 60.0,
167
- multiplier: 1.3,
168
- retry_codes: [8, 14, 13, 4]
131
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4]
169
132
  }
170
133
 
171
134
  default_config.rpcs.batch_write.timeout = 60.0
172
135
  default_config.rpcs.batch_write.retry_policy = {
173
- initial_delay: 0.1,
174
- max_delay: 60.0,
175
- multiplier: 1.3,
176
- retry_codes: [8, 14, 10]
136
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 10]
177
137
  }
178
138
 
179
139
  default_config.rpcs.create_document.timeout = 60.0
180
140
  default_config.rpcs.create_document.retry_policy = {
181
- initial_delay: 0.1,
182
- max_delay: 60.0,
183
- multiplier: 1.3,
184
- retry_codes: [8, 14]
141
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14]
185
142
  }
186
143
 
187
144
  default_config
@@ -213,19 +170,15 @@ module Google
213
170
  ##
214
171
  # Create a new Firestore client object.
215
172
  #
216
- # ## Examples
217
- #
218
- # To create a new Firestore client with the default
219
- # configuration:
173
+ # @example
220
174
  #
221
- # client = ::Google::Cloud::Firestore::V1::Firestore::Client.new
175
+ # # Create a client using the default configuration
176
+ # client = ::Google::Cloud::Firestore::V1::Firestore::Client.new
222
177
  #
223
- # To create a new Firestore client with a custom
224
- # configuration:
225
- #
226
- # client = ::Google::Cloud::Firestore::V1::Firestore::Client.new do |config|
227
- # config.timeout = 10.0
228
- # end
178
+ # # Create a client using a custom configuration
179
+ # client = ::Google::Cloud::Firestore::V1::Firestore::Client.new do |config|
180
+ # config.timeout = 10.0
181
+ # end
229
182
  #
230
183
  # @yield [config] Configure the Firestore client.
231
184
  # @yieldparam config [Client::Configuration]
@@ -245,14 +198,13 @@ module Google
245
198
 
246
199
  # Create credentials
247
200
  credentials = @config.credentials
248
- # Use self-signed JWT if the scope and endpoint are unchanged from default,
201
+ # Use self-signed JWT if the endpoint is unchanged from default,
249
202
  # but only if the default endpoint does not have a region prefix.
250
- enable_self_signed_jwt = @config.scope == Client.configure.scope &&
251
- @config.endpoint == Client.configure.endpoint &&
203
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
252
204
  !@config.endpoint.split(".").first.include?("-")
253
205
  credentials ||= Credentials.default scope: @config.scope,
254
206
  enable_self_signed_jwt: enable_self_signed_jwt
255
- if credentials.is_a?(String) || credentials.is_a?(Hash)
207
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
256
208
  credentials = Credentials.new credentials, scope: @config.scope
257
209
  end
258
210
  @quota_project_id = @config.quota_project
@@ -309,6 +261,21 @@ module Google
309
261
  #
310
262
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
311
263
  #
264
+ # @example Basic example
265
+ # require "google/cloud/firestore/v1"
266
+ #
267
+ # # Create a client object. The client can be reused for multiple calls.
268
+ # client = Google::Cloud::Firestore::V1::Firestore::Client.new
269
+ #
270
+ # # Create a request. To set request fields, pass in keyword arguments.
271
+ # request = Google::Cloud::Firestore::V1::GetDocumentRequest.new
272
+ #
273
+ # # Call the get_document method.
274
+ # result = client.get_document request
275
+ #
276
+ # # The returned object is of type Google::Cloud::Firestore::V1::Document.
277
+ # p result
278
+ #
312
279
  def get_document request, options = nil
313
280
  raise ::ArgumentError, "request must be provided" if request.nil?
314
281
 
@@ -326,16 +293,20 @@ module Google
326
293
  gapic_version: ::Google::Cloud::Firestore::V1::VERSION
327
294
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
328
295
 
329
- header_params = {
330
- "name" => request.name
331
- }
296
+ header_params = {}
297
+ if request.name
298
+ header_params["name"] = request.name
299
+ end
300
+
332
301
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
333
302
  metadata[:"x-goog-request-params"] ||= request_params_header
334
303
 
335
304
  options.apply_defaults timeout: @config.rpcs.get_document.timeout,
336
305
  metadata: metadata,
337
306
  retry_policy: @config.rpcs.get_document.retry_policy
338
- options.apply_defaults metadata: @config.metadata,
307
+
308
+ options.apply_defaults timeout: @config.timeout,
309
+ metadata: @config.metadata,
339
310
  retry_policy: @config.retry_policy
340
311
 
341
312
  @firestore_stub.call_rpc :get_document, request, options: options do |response, operation|
@@ -407,6 +378,27 @@ module Google
407
378
  #
408
379
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
409
380
  #
381
+ # @example Basic example
382
+ # require "google/cloud/firestore/v1"
383
+ #
384
+ # # Create a client object. The client can be reused for multiple calls.
385
+ # client = Google::Cloud::Firestore::V1::Firestore::Client.new
386
+ #
387
+ # # Create a request. To set request fields, pass in keyword arguments.
388
+ # request = Google::Cloud::Firestore::V1::ListDocumentsRequest.new
389
+ #
390
+ # # Call the list_documents method.
391
+ # result = client.list_documents request
392
+ #
393
+ # # The returned object is of type Gapic::PagedEnumerable. You can
394
+ # # iterate over all elements by calling #each, and the enumerable
395
+ # # will lazily make API calls to fetch subsequent pages. Other
396
+ # # methods are also available for managing paging directly.
397
+ # result.each do |response|
398
+ # # Each element is of type ::Google::Cloud::Firestore::V1::Document.
399
+ # p response
400
+ # end
401
+ #
410
402
  def list_documents request, options = nil
411
403
  raise ::ArgumentError, "request must be provided" if request.nil?
412
404
 
@@ -424,17 +416,23 @@ module Google
424
416
  gapic_version: ::Google::Cloud::Firestore::V1::VERSION
425
417
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
426
418
 
427
- header_params = {
428
- "parent" => request.parent,
429
- "collection_id" => request.collection_id
430
- }
419
+ header_params = {}
420
+ if request.parent
421
+ header_params["parent"] = request.parent
422
+ end
423
+ if request.collection_id
424
+ header_params["collection_id"] = request.collection_id
425
+ end
426
+
431
427
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
432
428
  metadata[:"x-goog-request-params"] ||= request_params_header
433
429
 
434
430
  options.apply_defaults timeout: @config.rpcs.list_documents.timeout,
435
431
  metadata: metadata,
436
432
  retry_policy: @config.rpcs.list_documents.retry_policy
437
- options.apply_defaults metadata: @config.metadata,
433
+
434
+ options.apply_defaults timeout: @config.timeout,
435
+ metadata: @config.metadata,
438
436
  retry_policy: @config.retry_policy
439
437
 
440
438
  @firestore_stub.call_rpc :list_documents, request, options: options do |response, operation|
@@ -492,6 +490,21 @@ module Google
492
490
  #
493
491
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
494
492
  #
493
+ # @example Basic example
494
+ # require "google/cloud/firestore/v1"
495
+ #
496
+ # # Create a client object. The client can be reused for multiple calls.
497
+ # client = Google::Cloud::Firestore::V1::Firestore::Client.new
498
+ #
499
+ # # Create a request. To set request fields, pass in keyword arguments.
500
+ # request = Google::Cloud::Firestore::V1::UpdateDocumentRequest.new
501
+ #
502
+ # # Call the update_document method.
503
+ # result = client.update_document request
504
+ #
505
+ # # The returned object is of type Google::Cloud::Firestore::V1::Document.
506
+ # p result
507
+ #
495
508
  def update_document request, options = nil
496
509
  raise ::ArgumentError, "request must be provided" if request.nil?
497
510
 
@@ -509,16 +522,20 @@ module Google
509
522
  gapic_version: ::Google::Cloud::Firestore::V1::VERSION
510
523
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
511
524
 
512
- header_params = {
513
- "document.name" => request.document.name
514
- }
525
+ header_params = {}
526
+ if request.document&.name
527
+ header_params["document.name"] = request.document.name
528
+ end
529
+
515
530
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
516
531
  metadata[:"x-goog-request-params"] ||= request_params_header
517
532
 
518
533
  options.apply_defaults timeout: @config.rpcs.update_document.timeout,
519
534
  metadata: metadata,
520
535
  retry_policy: @config.rpcs.update_document.retry_policy
521
- options.apply_defaults metadata: @config.metadata,
536
+
537
+ options.apply_defaults timeout: @config.timeout,
538
+ metadata: @config.metadata,
522
539
  retry_policy: @config.retry_policy
523
540
 
524
541
  @firestore_stub.call_rpc :update_document, request, options: options do |response, operation|
@@ -562,6 +579,21 @@ module Google
562
579
  #
563
580
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
564
581
  #
582
+ # @example Basic example
583
+ # require "google/cloud/firestore/v1"
584
+ #
585
+ # # Create a client object. The client can be reused for multiple calls.
586
+ # client = Google::Cloud::Firestore::V1::Firestore::Client.new
587
+ #
588
+ # # Create a request. To set request fields, pass in keyword arguments.
589
+ # request = Google::Cloud::Firestore::V1::DeleteDocumentRequest.new
590
+ #
591
+ # # Call the delete_document method.
592
+ # result = client.delete_document request
593
+ #
594
+ # # The returned object is of type Google::Protobuf::Empty.
595
+ # p result
596
+ #
565
597
  def delete_document request, options = nil
566
598
  raise ::ArgumentError, "request must be provided" if request.nil?
567
599
 
@@ -579,16 +611,20 @@ module Google
579
611
  gapic_version: ::Google::Cloud::Firestore::V1::VERSION
580
612
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
581
613
 
582
- header_params = {
583
- "name" => request.name
584
- }
614
+ header_params = {}
615
+ if request.name
616
+ header_params["name"] = request.name
617
+ end
618
+
585
619
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
586
620
  metadata[:"x-goog-request-params"] ||= request_params_header
587
621
 
588
622
  options.apply_defaults timeout: @config.rpcs.delete_document.timeout,
589
623
  metadata: metadata,
590
624
  retry_policy: @config.rpcs.delete_document.retry_policy
591
- options.apply_defaults metadata: @config.metadata,
625
+
626
+ options.apply_defaults timeout: @config.timeout,
627
+ metadata: @config.metadata,
592
628
  retry_policy: @config.retry_policy
593
629
 
594
630
  @firestore_stub.call_rpc :delete_document, request, options: options do |response, operation|
@@ -652,6 +688,24 @@ module Google
652
688
  #
653
689
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
654
690
  #
691
+ # @example Basic example
692
+ # require "google/cloud/firestore/v1"
693
+ #
694
+ # # Create a client object. The client can be reused for multiple calls.
695
+ # client = Google::Cloud::Firestore::V1::Firestore::Client.new
696
+ #
697
+ # # Create a request. To set request fields, pass in keyword arguments.
698
+ # request = Google::Cloud::Firestore::V1::BatchGetDocumentsRequest.new
699
+ #
700
+ # # Call the batch_get_documents method.
701
+ # result = client.batch_get_documents request
702
+ #
703
+ # # The returned object is a streamed enumerable yielding elements of
704
+ # # type ::Google::Cloud::Firestore::V1::BatchGetDocumentsResponse.
705
+ # result.each do |response|
706
+ # p response
707
+ # end
708
+ #
655
709
  def batch_get_documents request, options = nil
656
710
  raise ::ArgumentError, "request must be provided" if request.nil?
657
711
 
@@ -669,16 +723,20 @@ module Google
669
723
  gapic_version: ::Google::Cloud::Firestore::V1::VERSION
670
724
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
671
725
 
672
- header_params = {
673
- "database" => request.database
674
- }
726
+ header_params = {}
727
+ if request.database
728
+ header_params["database"] = request.database
729
+ end
730
+
675
731
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
676
732
  metadata[:"x-goog-request-params"] ||= request_params_header
677
733
 
678
734
  options.apply_defaults timeout: @config.rpcs.batch_get_documents.timeout,
679
735
  metadata: metadata,
680
736
  retry_policy: @config.rpcs.batch_get_documents.retry_policy
681
- options.apply_defaults metadata: @config.metadata,
737
+
738
+ options.apply_defaults timeout: @config.timeout,
739
+ metadata: @config.metadata,
682
740
  retry_policy: @config.retry_policy
683
741
 
684
742
  @firestore_stub.call_rpc :batch_get_documents, request, options: options do |response, operation|
@@ -722,6 +780,21 @@ module Google
722
780
  #
723
781
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
724
782
  #
783
+ # @example Basic example
784
+ # require "google/cloud/firestore/v1"
785
+ #
786
+ # # Create a client object. The client can be reused for multiple calls.
787
+ # client = Google::Cloud::Firestore::V1::Firestore::Client.new
788
+ #
789
+ # # Create a request. To set request fields, pass in keyword arguments.
790
+ # request = Google::Cloud::Firestore::V1::BeginTransactionRequest.new
791
+ #
792
+ # # Call the begin_transaction method.
793
+ # result = client.begin_transaction request
794
+ #
795
+ # # The returned object is of type Google::Cloud::Firestore::V1::BeginTransactionResponse.
796
+ # p result
797
+ #
725
798
  def begin_transaction request, options = nil
726
799
  raise ::ArgumentError, "request must be provided" if request.nil?
727
800
 
@@ -739,16 +812,20 @@ module Google
739
812
  gapic_version: ::Google::Cloud::Firestore::V1::VERSION
740
813
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
741
814
 
742
- header_params = {
743
- "database" => request.database
744
- }
815
+ header_params = {}
816
+ if request.database
817
+ header_params["database"] = request.database
818
+ end
819
+
745
820
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
746
821
  metadata[:"x-goog-request-params"] ||= request_params_header
747
822
 
748
823
  options.apply_defaults timeout: @config.rpcs.begin_transaction.timeout,
749
824
  metadata: metadata,
750
825
  retry_policy: @config.rpcs.begin_transaction.retry_policy
751
- options.apply_defaults metadata: @config.metadata,
826
+
827
+ options.apply_defaults timeout: @config.timeout,
828
+ metadata: @config.metadata,
752
829
  retry_policy: @config.retry_policy
753
830
 
754
831
  @firestore_stub.call_rpc :begin_transaction, request, options: options do |response, operation|
@@ -795,6 +872,21 @@ module Google
795
872
  #
796
873
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
797
874
  #
875
+ # @example Basic example
876
+ # require "google/cloud/firestore/v1"
877
+ #
878
+ # # Create a client object. The client can be reused for multiple calls.
879
+ # client = Google::Cloud::Firestore::V1::Firestore::Client.new
880
+ #
881
+ # # Create a request. To set request fields, pass in keyword arguments.
882
+ # request = Google::Cloud::Firestore::V1::CommitRequest.new
883
+ #
884
+ # # Call the commit method.
885
+ # result = client.commit request
886
+ #
887
+ # # The returned object is of type Google::Cloud::Firestore::V1::CommitResponse.
888
+ # p result
889
+ #
798
890
  def commit request, options = nil
799
891
  raise ::ArgumentError, "request must be provided" if request.nil?
800
892
 
@@ -812,16 +904,20 @@ module Google
812
904
  gapic_version: ::Google::Cloud::Firestore::V1::VERSION
813
905
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
814
906
 
815
- header_params = {
816
- "database" => request.database
817
- }
907
+ header_params = {}
908
+ if request.database
909
+ header_params["database"] = request.database
910
+ end
911
+
818
912
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
819
913
  metadata[:"x-goog-request-params"] ||= request_params_header
820
914
 
821
915
  options.apply_defaults timeout: @config.rpcs.commit.timeout,
822
916
  metadata: metadata,
823
917
  retry_policy: @config.rpcs.commit.retry_policy
824
- options.apply_defaults metadata: @config.metadata,
918
+
919
+ options.apply_defaults timeout: @config.timeout,
920
+ metadata: @config.metadata,
825
921
  retry_policy: @config.retry_policy
826
922
 
827
923
  @firestore_stub.call_rpc :commit, request, options: options do |response, operation|
@@ -864,6 +960,21 @@ module Google
864
960
  #
865
961
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
866
962
  #
963
+ # @example Basic example
964
+ # require "google/cloud/firestore/v1"
965
+ #
966
+ # # Create a client object. The client can be reused for multiple calls.
967
+ # client = Google::Cloud::Firestore::V1::Firestore::Client.new
968
+ #
969
+ # # Create a request. To set request fields, pass in keyword arguments.
970
+ # request = Google::Cloud::Firestore::V1::RollbackRequest.new
971
+ #
972
+ # # Call the rollback method.
973
+ # result = client.rollback request
974
+ #
975
+ # # The returned object is of type Google::Protobuf::Empty.
976
+ # p result
977
+ #
867
978
  def rollback request, options = nil
868
979
  raise ::ArgumentError, "request must be provided" if request.nil?
869
980
 
@@ -881,16 +992,20 @@ module Google
881
992
  gapic_version: ::Google::Cloud::Firestore::V1::VERSION
882
993
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
883
994
 
884
- header_params = {
885
- "database" => request.database
886
- }
995
+ header_params = {}
996
+ if request.database
997
+ header_params["database"] = request.database
998
+ end
999
+
887
1000
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
888
1001
  metadata[:"x-goog-request-params"] ||= request_params_header
889
1002
 
890
1003
  options.apply_defaults timeout: @config.rpcs.rollback.timeout,
891
1004
  metadata: metadata,
892
1005
  retry_policy: @config.rpcs.rollback.retry_policy
893
- options.apply_defaults metadata: @config.metadata,
1006
+
1007
+ options.apply_defaults timeout: @config.timeout,
1008
+ metadata: @config.metadata,
894
1009
  retry_policy: @config.retry_policy
895
1010
 
896
1011
  @firestore_stub.call_rpc :rollback, request, options: options do |response, operation|
@@ -947,6 +1062,24 @@ module Google
947
1062
  #
948
1063
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
949
1064
  #
1065
+ # @example Basic example
1066
+ # require "google/cloud/firestore/v1"
1067
+ #
1068
+ # # Create a client object. The client can be reused for multiple calls.
1069
+ # client = Google::Cloud::Firestore::V1::Firestore::Client.new
1070
+ #
1071
+ # # Create a request. To set request fields, pass in keyword arguments.
1072
+ # request = Google::Cloud::Firestore::V1::RunQueryRequest.new
1073
+ #
1074
+ # # Call the run_query method.
1075
+ # result = client.run_query request
1076
+ #
1077
+ # # The returned object is a streamed enumerable yielding elements of
1078
+ # # type ::Google::Cloud::Firestore::V1::RunQueryResponse.
1079
+ # result.each do |response|
1080
+ # p response
1081
+ # end
1082
+ #
950
1083
  def run_query request, options = nil
951
1084
  raise ::ArgumentError, "request must be provided" if request.nil?
952
1085
 
@@ -964,16 +1097,20 @@ module Google
964
1097
  gapic_version: ::Google::Cloud::Firestore::V1::VERSION
965
1098
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
966
1099
 
967
- header_params = {
968
- "parent" => request.parent
969
- }
1100
+ header_params = {}
1101
+ if request.parent
1102
+ header_params["parent"] = request.parent
1103
+ end
1104
+
970
1105
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
971
1106
  metadata[:"x-goog-request-params"] ||= request_params_header
972
1107
 
973
1108
  options.apply_defaults timeout: @config.rpcs.run_query.timeout,
974
1109
  metadata: metadata,
975
1110
  retry_policy: @config.rpcs.run_query.retry_policy
976
- options.apply_defaults metadata: @config.metadata,
1111
+
1112
+ options.apply_defaults timeout: @config.timeout,
1113
+ metadata: @config.metadata,
977
1114
  retry_policy: @config.retry_policy
978
1115
 
979
1116
  @firestore_stub.call_rpc :run_query, request, options: options do |response, operation|
@@ -1054,6 +1191,27 @@ module Google
1054
1191
  #
1055
1192
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1056
1193
  #
1194
+ # @example Basic example
1195
+ # require "google/cloud/firestore/v1"
1196
+ #
1197
+ # # Create a client object. The client can be reused for multiple calls.
1198
+ # client = Google::Cloud::Firestore::V1::Firestore::Client.new
1199
+ #
1200
+ # # Create a request. To set request fields, pass in keyword arguments.
1201
+ # request = Google::Cloud::Firestore::V1::PartitionQueryRequest.new
1202
+ #
1203
+ # # Call the partition_query method.
1204
+ # result = client.partition_query request
1205
+ #
1206
+ # # The returned object is of type Gapic::PagedEnumerable. You can
1207
+ # # iterate over all elements by calling #each, and the enumerable
1208
+ # # will lazily make API calls to fetch subsequent pages. Other
1209
+ # # methods are also available for managing paging directly.
1210
+ # result.each do |response|
1211
+ # # Each element is of type ::Google::Cloud::Firestore::V1::Cursor.
1212
+ # p response
1213
+ # end
1214
+ #
1057
1215
  def partition_query request, options = nil
1058
1216
  raise ::ArgumentError, "request must be provided" if request.nil?
1059
1217
 
@@ -1071,16 +1229,20 @@ module Google
1071
1229
  gapic_version: ::Google::Cloud::Firestore::V1::VERSION
1072
1230
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1073
1231
 
1074
- header_params = {
1075
- "parent" => request.parent
1076
- }
1232
+ header_params = {}
1233
+ if request.parent
1234
+ header_params["parent"] = request.parent
1235
+ end
1236
+
1077
1237
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1078
1238
  metadata[:"x-goog-request-params"] ||= request_params_header
1079
1239
 
1080
1240
  options.apply_defaults timeout: @config.rpcs.partition_query.timeout,
1081
1241
  metadata: metadata,
1082
1242
  retry_policy: @config.rpcs.partition_query.retry_policy
1083
- options.apply_defaults metadata: @config.metadata,
1243
+
1244
+ options.apply_defaults timeout: @config.timeout,
1245
+ metadata: @config.metadata,
1084
1246
  retry_policy: @config.retry_policy
1085
1247
 
1086
1248
  @firestore_stub.call_rpc :partition_query, request, options: options do |response, operation|
@@ -1108,6 +1270,30 @@ module Google
1108
1270
  #
1109
1271
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1110
1272
  #
1273
+ # @example Basic example
1274
+ # require "google/cloud/firestore/v1"
1275
+ #
1276
+ # # Create a client object. The client can be reused for multiple calls.
1277
+ # client = Google::Cloud::Firestore::V1::Firestore::Client.new
1278
+ #
1279
+ # # Create an input stream
1280
+ # input = Gapic::StreamInput.new
1281
+ #
1282
+ # # Call the write method to start streaming.
1283
+ # output = client.write input
1284
+ #
1285
+ # # Send requests on the stream. For each request, pass in keyword
1286
+ # # arguments to set fields. Be sure to close the stream when done.
1287
+ # input << Google::Cloud::Firestore::V1::WriteRequest.new
1288
+ # input << Google::Cloud::Firestore::V1::WriteRequest.new
1289
+ # input.close
1290
+ #
1291
+ # # Handle streamed responses. These may be interleaved with inputs.
1292
+ # # Each response is of type ::Google::Cloud::Firestore::V1::WriteResponse.
1293
+ # output.each do |response|
1294
+ # p response
1295
+ # end
1296
+ #
1111
1297
  def write request, options = nil
1112
1298
  unless request.is_a? ::Enumerable
1113
1299
  raise ::ArgumentError, "request must be an Enumerable" unless request.respond_to? :to_enum
@@ -1133,7 +1319,9 @@ module Google
1133
1319
  options.apply_defaults timeout: @config.rpcs.write.timeout,
1134
1320
  metadata: metadata,
1135
1321
  retry_policy: @config.rpcs.write.retry_policy
1136
- options.apply_defaults metadata: @config.metadata,
1322
+
1323
+ options.apply_defaults timeout: @config.timeout,
1324
+ metadata: @config.metadata,
1137
1325
  retry_policy: @config.retry_policy
1138
1326
 
1139
1327
  @firestore_stub.call_rpc :write, request, options: options do |response, operation|
@@ -1160,6 +1348,30 @@ module Google
1160
1348
  #
1161
1349
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1162
1350
  #
1351
+ # @example Basic example
1352
+ # require "google/cloud/firestore/v1"
1353
+ #
1354
+ # # Create a client object. The client can be reused for multiple calls.
1355
+ # client = Google::Cloud::Firestore::V1::Firestore::Client.new
1356
+ #
1357
+ # # Create an input stream
1358
+ # input = Gapic::StreamInput.new
1359
+ #
1360
+ # # Call the listen method to start streaming.
1361
+ # output = client.listen input
1362
+ #
1363
+ # # Send requests on the stream. For each request, pass in keyword
1364
+ # # arguments to set fields. Be sure to close the stream when done.
1365
+ # input << Google::Cloud::Firestore::V1::ListenRequest.new
1366
+ # input << Google::Cloud::Firestore::V1::ListenRequest.new
1367
+ # input.close
1368
+ #
1369
+ # # Handle streamed responses. These may be interleaved with inputs.
1370
+ # # Each response is of type ::Google::Cloud::Firestore::V1::ListenResponse.
1371
+ # output.each do |response|
1372
+ # p response
1373
+ # end
1374
+ #
1163
1375
  def listen request, options = nil
1164
1376
  unless request.is_a? ::Enumerable
1165
1377
  raise ::ArgumentError, "request must be an Enumerable" unless request.respond_to? :to_enum
@@ -1185,7 +1397,9 @@ module Google
1185
1397
  options.apply_defaults timeout: @config.rpcs.listen.timeout,
1186
1398
  metadata: metadata,
1187
1399
  retry_policy: @config.rpcs.listen.retry_policy
1188
- options.apply_defaults metadata: @config.metadata,
1400
+
1401
+ options.apply_defaults timeout: @config.timeout,
1402
+ metadata: @config.metadata,
1189
1403
  retry_policy: @config.retry_policy
1190
1404
 
1191
1405
  @firestore_stub.call_rpc :listen, request, options: options do |response, operation|
@@ -1233,6 +1447,21 @@ module Google
1233
1447
  #
1234
1448
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1235
1449
  #
1450
+ # @example Basic example
1451
+ # require "google/cloud/firestore/v1"
1452
+ #
1453
+ # # Create a client object. The client can be reused for multiple calls.
1454
+ # client = Google::Cloud::Firestore::V1::Firestore::Client.new
1455
+ #
1456
+ # # Create a request. To set request fields, pass in keyword arguments.
1457
+ # request = Google::Cloud::Firestore::V1::ListCollectionIdsRequest.new
1458
+ #
1459
+ # # Call the list_collection_ids method.
1460
+ # result = client.list_collection_ids request
1461
+ #
1462
+ # # The returned object is of type Google::Cloud::Firestore::V1::ListCollectionIdsResponse.
1463
+ # p result
1464
+ #
1236
1465
  def list_collection_ids request, options = nil
1237
1466
  raise ::ArgumentError, "request must be provided" if request.nil?
1238
1467
 
@@ -1250,16 +1479,20 @@ module Google
1250
1479
  gapic_version: ::Google::Cloud::Firestore::V1::VERSION
1251
1480
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1252
1481
 
1253
- header_params = {
1254
- "parent" => request.parent
1255
- }
1482
+ header_params = {}
1483
+ if request.parent
1484
+ header_params["parent"] = request.parent
1485
+ end
1486
+
1256
1487
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1257
1488
  metadata[:"x-goog-request-params"] ||= request_params_header
1258
1489
 
1259
1490
  options.apply_defaults timeout: @config.rpcs.list_collection_ids.timeout,
1260
1491
  metadata: metadata,
1261
1492
  retry_policy: @config.rpcs.list_collection_ids.retry_policy
1262
- options.apply_defaults metadata: @config.metadata,
1493
+
1494
+ options.apply_defaults timeout: @config.timeout,
1495
+ metadata: @config.metadata,
1263
1496
  retry_policy: @config.retry_policy
1264
1497
 
1265
1498
  @firestore_stub.call_rpc :list_collection_ids, request, options: options do |response, operation|
@@ -1316,6 +1549,21 @@ module Google
1316
1549
  #
1317
1550
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1318
1551
  #
1552
+ # @example Basic example
1553
+ # require "google/cloud/firestore/v1"
1554
+ #
1555
+ # # Create a client object. The client can be reused for multiple calls.
1556
+ # client = Google::Cloud::Firestore::V1::Firestore::Client.new
1557
+ #
1558
+ # # Create a request. To set request fields, pass in keyword arguments.
1559
+ # request = Google::Cloud::Firestore::V1::BatchWriteRequest.new
1560
+ #
1561
+ # # Call the batch_write method.
1562
+ # result = client.batch_write request
1563
+ #
1564
+ # # The returned object is of type Google::Cloud::Firestore::V1::BatchWriteResponse.
1565
+ # p result
1566
+ #
1319
1567
  def batch_write request, options = nil
1320
1568
  raise ::ArgumentError, "request must be provided" if request.nil?
1321
1569
 
@@ -1333,16 +1581,20 @@ module Google
1333
1581
  gapic_version: ::Google::Cloud::Firestore::V1::VERSION
1334
1582
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1335
1583
 
1336
- header_params = {
1337
- "database" => request.database
1338
- }
1584
+ header_params = {}
1585
+ if request.database
1586
+ header_params["database"] = request.database
1587
+ end
1588
+
1339
1589
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1340
1590
  metadata[:"x-goog-request-params"] ||= request_params_header
1341
1591
 
1342
1592
  options.apply_defaults timeout: @config.rpcs.batch_write.timeout,
1343
1593
  metadata: metadata,
1344
1594
  retry_policy: @config.rpcs.batch_write.retry_policy
1345
- options.apply_defaults metadata: @config.metadata,
1595
+
1596
+ options.apply_defaults timeout: @config.timeout,
1597
+ metadata: @config.metadata,
1346
1598
  retry_policy: @config.retry_policy
1347
1599
 
1348
1600
  @firestore_stub.call_rpc :batch_write, request, options: options do |response, operation|
@@ -1397,6 +1649,21 @@ module Google
1397
1649
  #
1398
1650
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1399
1651
  #
1652
+ # @example Basic example
1653
+ # require "google/cloud/firestore/v1"
1654
+ #
1655
+ # # Create a client object. The client can be reused for multiple calls.
1656
+ # client = Google::Cloud::Firestore::V1::Firestore::Client.new
1657
+ #
1658
+ # # Create a request. To set request fields, pass in keyword arguments.
1659
+ # request = Google::Cloud::Firestore::V1::CreateDocumentRequest.new
1660
+ #
1661
+ # # Call the create_document method.
1662
+ # result = client.create_document request
1663
+ #
1664
+ # # The returned object is of type Google::Cloud::Firestore::V1::Document.
1665
+ # p result
1666
+ #
1400
1667
  def create_document request, options = nil
1401
1668
  raise ::ArgumentError, "request must be provided" if request.nil?
1402
1669
 
@@ -1414,17 +1681,23 @@ module Google
1414
1681
  gapic_version: ::Google::Cloud::Firestore::V1::VERSION
1415
1682
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1416
1683
 
1417
- header_params = {
1418
- "parent" => request.parent,
1419
- "collection_id" => request.collection_id
1420
- }
1684
+ header_params = {}
1685
+ if request.parent
1686
+ header_params["parent"] = request.parent
1687
+ end
1688
+ if request.collection_id
1689
+ header_params["collection_id"] = request.collection_id
1690
+ end
1691
+
1421
1692
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1422
1693
  metadata[:"x-goog-request-params"] ||= request_params_header
1423
1694
 
1424
1695
  options.apply_defaults timeout: @config.rpcs.create_document.timeout,
1425
1696
  metadata: metadata,
1426
1697
  retry_policy: @config.rpcs.create_document.retry_policy
1427
- options.apply_defaults metadata: @config.metadata,
1698
+
1699
+ options.apply_defaults timeout: @config.timeout,
1700
+ metadata: @config.metadata,
1428
1701
  retry_policy: @config.retry_policy
1429
1702
 
1430
1703
  @firestore_stub.call_rpc :create_document, request, options: options do |response, operation|
@@ -1448,22 +1721,21 @@ module Google
1448
1721
  # Configuration can be applied globally to all clients, or to a single client
1449
1722
  # on construction.
1450
1723
  #
1451
- # # Examples
1452
- #
1453
- # To modify the global config, setting the timeout for get_document
1454
- # to 20 seconds, and all remaining timeouts to 10 seconds:
1455
- #
1456
- # ::Google::Cloud::Firestore::V1::Firestore::Client.configure do |config|
1457
- # config.timeout = 10.0
1458
- # config.rpcs.get_document.timeout = 20.0
1459
- # end
1460
- #
1461
- # To apply the above configuration only to a new client:
1462
- #
1463
- # client = ::Google::Cloud::Firestore::V1::Firestore::Client.new do |config|
1464
- # config.timeout = 10.0
1465
- # config.rpcs.get_document.timeout = 20.0
1466
- # end
1724
+ # @example
1725
+ #
1726
+ # # Modify the global config, setting the timeout for
1727
+ # # get_document to 20 seconds,
1728
+ # # and all remaining timeouts to 10 seconds.
1729
+ # ::Google::Cloud::Firestore::V1::Firestore::Client.configure do |config|
1730
+ # config.timeout = 10.0
1731
+ # config.rpcs.get_document.timeout = 20.0
1732
+ # end
1733
+ #
1734
+ # # Apply the above configuration only to a new client.
1735
+ # client = ::Google::Cloud::Firestore::V1::Firestore::Client.new do |config|
1736
+ # config.timeout = 10.0
1737
+ # config.rpcs.get_document.timeout = 20.0
1738
+ # end
1467
1739
  #
1468
1740
  # @!attribute [rw] endpoint
1469
1741
  # The hostname or hostname:port of the service endpoint.