google-cloud-firestore-v1 0.9.0 → 0.11.0

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.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +72 -101
  3. data/README.md +2 -2
  4. data/lib/google/cloud/firestore/v1/firestore/client.rb +81 -29
  5. data/lib/google/cloud/firestore/v1/firestore/rest/client.rb +1887 -0
  6. data/lib/google/cloud/firestore/v1/firestore/rest/service_stub.rb +933 -0
  7. data/lib/google/cloud/firestore/v1/firestore/rest.rb +58 -0
  8. data/lib/google/cloud/firestore/v1/firestore.rb +6 -0
  9. data/lib/google/cloud/firestore/v1/rest.rb +37 -0
  10. data/lib/google/cloud/firestore/v1/version.rb +1 -1
  11. data/lib/google/cloud/firestore/v1.rb +5 -0
  12. data/lib/google/firestore/v1/aggregation_result_pb.rb +25 -4
  13. data/lib/google/firestore/v1/bloom_filter_pb.rb +43 -0
  14. data/lib/google/firestore/v1/common_pb.rb +25 -24
  15. data/lib/google/firestore/v1/document_pb.rb +26 -28
  16. data/lib/google/firestore/v1/firestore_pb.rb +33 -219
  17. data/lib/google/firestore/v1/firestore_services_pb.rb +3 -3
  18. data/lib/google/firestore/v1/query_pb.rb +28 -96
  19. data/lib/google/firestore/v1/write_pb.rb +29 -53
  20. data/proto_docs/google/api/client.rb +81 -4
  21. data/proto_docs/google/api/field_behavior.rb +14 -0
  22. data/proto_docs/google/firestore/v1/bloom_filter.rb +79 -0
  23. data/proto_docs/google/firestore/v1/common.rb +7 -1
  24. data/proto_docs/google/firestore/v1/document.rb +12 -12
  25. data/proto_docs/google/firestore/v1/firestore.rb +58 -11
  26. data/proto_docs/google/firestore/v1/query.rb +82 -12
  27. data/proto_docs/google/firestore/v1/write.rb +18 -0
  28. data/proto_docs/google/protobuf/any.rb +7 -4
  29. data/proto_docs/google/protobuf/struct.rb +1 -1
  30. data/proto_docs/google/protobuf/timestamp.rb +1 -3
  31. metadata +15 -8
@@ -0,0 +1,933 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/firestore/v1/firestore_pb"
20
+
21
+ module Google
22
+ module Cloud
23
+ module Firestore
24
+ module V1
25
+ module Firestore
26
+ module Rest
27
+ ##
28
+ # REST service stub for the Firestore service.
29
+ # Service stub contains baseline method implementations
30
+ # including transcoding, making the REST call, and deserialing the response.
31
+ #
32
+ class ServiceStub
33
+ def initialize endpoint:, endpoint_template:, universe_domain:, credentials:
34
+ # These require statements are intentionally placed here to initialize
35
+ # the REST modules only when it's required.
36
+ require "gapic/rest"
37
+
38
+ @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint,
39
+ endpoint_template: endpoint_template,
40
+ universe_domain: universe_domain,
41
+ credentials: credentials,
42
+ numeric_enums: true,
43
+ raise_faraday_errors: false
44
+ end
45
+
46
+ ##
47
+ # The effective universe domain
48
+ #
49
+ # @return [String]
50
+ #
51
+ def universe_domain
52
+ @client_stub.universe_domain
53
+ end
54
+
55
+ ##
56
+ # The effective endpoint
57
+ #
58
+ # @return [String]
59
+ #
60
+ def endpoint
61
+ @client_stub.endpoint
62
+ end
63
+
64
+ ##
65
+ # Baseline implementation for the get_document REST call
66
+ #
67
+ # @param request_pb [::Google::Cloud::Firestore::V1::GetDocumentRequest]
68
+ # A request object representing the call parameters. Required.
69
+ # @param options [::Gapic::CallOptions]
70
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
71
+ #
72
+ # @yield [result, operation] Access the result along with the TransportOperation object
73
+ # @yieldparam result [::Google::Cloud::Firestore::V1::Document]
74
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
75
+ #
76
+ # @return [::Google::Cloud::Firestore::V1::Document]
77
+ # A result object deserialized from the server's reply
78
+ def get_document request_pb, options = nil
79
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
80
+
81
+ verb, uri, query_string_params, body = ServiceStub.transcode_get_document_request request_pb
82
+ query_string_params = if query_string_params.any?
83
+ query_string_params.to_h { |p| p.split "=", 2 }
84
+ else
85
+ {}
86
+ end
87
+
88
+ response = @client_stub.make_http_request(
89
+ verb,
90
+ uri: uri,
91
+ body: body || "",
92
+ params: query_string_params,
93
+ options: options
94
+ )
95
+ operation = ::Gapic::Rest::TransportOperation.new response
96
+ result = ::Google::Cloud::Firestore::V1::Document.decode_json response.body, ignore_unknown_fields: true
97
+
98
+ yield result, operation if block_given?
99
+ result
100
+ end
101
+
102
+ ##
103
+ # Baseline implementation for the list_documents REST call
104
+ #
105
+ # @param request_pb [::Google::Cloud::Firestore::V1::ListDocumentsRequest]
106
+ # A request object representing the call parameters. Required.
107
+ # @param options [::Gapic::CallOptions]
108
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
109
+ #
110
+ # @yield [result, operation] Access the result along with the TransportOperation object
111
+ # @yieldparam result [::Google::Cloud::Firestore::V1::ListDocumentsResponse]
112
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
113
+ #
114
+ # @return [::Google::Cloud::Firestore::V1::ListDocumentsResponse]
115
+ # A result object deserialized from the server's reply
116
+ def list_documents request_pb, options = nil
117
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
118
+
119
+ verb, uri, query_string_params, body = ServiceStub.transcode_list_documents_request request_pb
120
+ query_string_params = if query_string_params.any?
121
+ query_string_params.to_h { |p| p.split "=", 2 }
122
+ else
123
+ {}
124
+ end
125
+
126
+ response = @client_stub.make_http_request(
127
+ verb,
128
+ uri: uri,
129
+ body: body || "",
130
+ params: query_string_params,
131
+ options: options
132
+ )
133
+ operation = ::Gapic::Rest::TransportOperation.new response
134
+ result = ::Google::Cloud::Firestore::V1::ListDocumentsResponse.decode_json response.body, ignore_unknown_fields: true
135
+
136
+ yield result, operation if block_given?
137
+ result
138
+ end
139
+
140
+ ##
141
+ # Baseline implementation for the update_document REST call
142
+ #
143
+ # @param request_pb [::Google::Cloud::Firestore::V1::UpdateDocumentRequest]
144
+ # A request object representing the call parameters. Required.
145
+ # @param options [::Gapic::CallOptions]
146
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
147
+ #
148
+ # @yield [result, operation] Access the result along with the TransportOperation object
149
+ # @yieldparam result [::Google::Cloud::Firestore::V1::Document]
150
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
151
+ #
152
+ # @return [::Google::Cloud::Firestore::V1::Document]
153
+ # A result object deserialized from the server's reply
154
+ def update_document request_pb, options = nil
155
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
156
+
157
+ verb, uri, query_string_params, body = ServiceStub.transcode_update_document_request request_pb
158
+ query_string_params = if query_string_params.any?
159
+ query_string_params.to_h { |p| p.split "=", 2 }
160
+ else
161
+ {}
162
+ end
163
+
164
+ response = @client_stub.make_http_request(
165
+ verb,
166
+ uri: uri,
167
+ body: body || "",
168
+ params: query_string_params,
169
+ options: options
170
+ )
171
+ operation = ::Gapic::Rest::TransportOperation.new response
172
+ result = ::Google::Cloud::Firestore::V1::Document.decode_json response.body, ignore_unknown_fields: true
173
+
174
+ yield result, operation if block_given?
175
+ result
176
+ end
177
+
178
+ ##
179
+ # Baseline implementation for the delete_document REST call
180
+ #
181
+ # @param request_pb [::Google::Cloud::Firestore::V1::DeleteDocumentRequest]
182
+ # A request object representing the call parameters. Required.
183
+ # @param options [::Gapic::CallOptions]
184
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
185
+ #
186
+ # @yield [result, operation] Access the result along with the TransportOperation object
187
+ # @yieldparam result [::Google::Protobuf::Empty]
188
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
189
+ #
190
+ # @return [::Google::Protobuf::Empty]
191
+ # A result object deserialized from the server's reply
192
+ def delete_document request_pb, options = nil
193
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
194
+
195
+ verb, uri, query_string_params, body = ServiceStub.transcode_delete_document_request request_pb
196
+ query_string_params = if query_string_params.any?
197
+ query_string_params.to_h { |p| p.split "=", 2 }
198
+ else
199
+ {}
200
+ end
201
+
202
+ response = @client_stub.make_http_request(
203
+ verb,
204
+ uri: uri,
205
+ body: body || "",
206
+ params: query_string_params,
207
+ options: options
208
+ )
209
+ operation = ::Gapic::Rest::TransportOperation.new response
210
+ result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
211
+
212
+ yield result, operation if block_given?
213
+ result
214
+ end
215
+
216
+ ##
217
+ # Baseline implementation for the batch_get_documents REST call
218
+ #
219
+ # @param request_pb [::Google::Cloud::Firestore::V1::BatchGetDocumentsRequest]
220
+ # A request object representing the call parameters. Required.
221
+ # @param options [::Gapic::CallOptions]
222
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
223
+ #
224
+ # @yieldparam chunk [::String] The chunk of data received during server streaming.
225
+ #
226
+ # @return [::Gapic::Rest::TransportOperation]
227
+ def batch_get_documents request_pb, options = nil, &block
228
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
229
+
230
+ verb, uri, query_string_params, body = ServiceStub.transcode_batch_get_documents_request request_pb
231
+ query_string_params = if query_string_params.any?
232
+ query_string_params.to_h { |p| p.split "=", 2 }
233
+ else
234
+ {}
235
+ end
236
+
237
+ response = @client_stub.make_http_request(
238
+ verb,
239
+ uri: uri,
240
+ body: body || "",
241
+ params: query_string_params,
242
+ options: options,
243
+ is_server_streaming: true,
244
+ &block
245
+ )
246
+ ::Gapic::Rest::TransportOperation.new response
247
+ end
248
+
249
+ ##
250
+ # Baseline implementation for the begin_transaction REST call
251
+ #
252
+ # @param request_pb [::Google::Cloud::Firestore::V1::BeginTransactionRequest]
253
+ # A request object representing the call parameters. Required.
254
+ # @param options [::Gapic::CallOptions]
255
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
256
+ #
257
+ # @yield [result, operation] Access the result along with the TransportOperation object
258
+ # @yieldparam result [::Google::Cloud::Firestore::V1::BeginTransactionResponse]
259
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
260
+ #
261
+ # @return [::Google::Cloud::Firestore::V1::BeginTransactionResponse]
262
+ # A result object deserialized from the server's reply
263
+ def begin_transaction request_pb, options = nil
264
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
265
+
266
+ verb, uri, query_string_params, body = ServiceStub.transcode_begin_transaction_request request_pb
267
+ query_string_params = if query_string_params.any?
268
+ query_string_params.to_h { |p| p.split "=", 2 }
269
+ else
270
+ {}
271
+ end
272
+
273
+ response = @client_stub.make_http_request(
274
+ verb,
275
+ uri: uri,
276
+ body: body || "",
277
+ params: query_string_params,
278
+ options: options
279
+ )
280
+ operation = ::Gapic::Rest::TransportOperation.new response
281
+ result = ::Google::Cloud::Firestore::V1::BeginTransactionResponse.decode_json response.body, ignore_unknown_fields: true
282
+
283
+ yield result, operation if block_given?
284
+ result
285
+ end
286
+
287
+ ##
288
+ # Baseline implementation for the commit REST call
289
+ #
290
+ # @param request_pb [::Google::Cloud::Firestore::V1::CommitRequest]
291
+ # A request object representing the call parameters. Required.
292
+ # @param options [::Gapic::CallOptions]
293
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
294
+ #
295
+ # @yield [result, operation] Access the result along with the TransportOperation object
296
+ # @yieldparam result [::Google::Cloud::Firestore::V1::CommitResponse]
297
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
298
+ #
299
+ # @return [::Google::Cloud::Firestore::V1::CommitResponse]
300
+ # A result object deserialized from the server's reply
301
+ def commit request_pb, options = nil
302
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
303
+
304
+ verb, uri, query_string_params, body = ServiceStub.transcode_commit_request request_pb
305
+ query_string_params = if query_string_params.any?
306
+ query_string_params.to_h { |p| p.split "=", 2 }
307
+ else
308
+ {}
309
+ end
310
+
311
+ response = @client_stub.make_http_request(
312
+ verb,
313
+ uri: uri,
314
+ body: body || "",
315
+ params: query_string_params,
316
+ options: options
317
+ )
318
+ operation = ::Gapic::Rest::TransportOperation.new response
319
+ result = ::Google::Cloud::Firestore::V1::CommitResponse.decode_json response.body, ignore_unknown_fields: true
320
+
321
+ yield result, operation if block_given?
322
+ result
323
+ end
324
+
325
+ ##
326
+ # Baseline implementation for the rollback REST call
327
+ #
328
+ # @param request_pb [::Google::Cloud::Firestore::V1::RollbackRequest]
329
+ # A request object representing the call parameters. Required.
330
+ # @param options [::Gapic::CallOptions]
331
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
332
+ #
333
+ # @yield [result, operation] Access the result along with the TransportOperation object
334
+ # @yieldparam result [::Google::Protobuf::Empty]
335
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
336
+ #
337
+ # @return [::Google::Protobuf::Empty]
338
+ # A result object deserialized from the server's reply
339
+ def rollback request_pb, options = nil
340
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
341
+
342
+ verb, uri, query_string_params, body = ServiceStub.transcode_rollback_request request_pb
343
+ query_string_params = if query_string_params.any?
344
+ query_string_params.to_h { |p| p.split "=", 2 }
345
+ else
346
+ {}
347
+ end
348
+
349
+ response = @client_stub.make_http_request(
350
+ verb,
351
+ uri: uri,
352
+ body: body || "",
353
+ params: query_string_params,
354
+ options: options
355
+ )
356
+ operation = ::Gapic::Rest::TransportOperation.new response
357
+ result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
358
+
359
+ yield result, operation if block_given?
360
+ result
361
+ end
362
+
363
+ ##
364
+ # Baseline implementation for the run_query REST call
365
+ #
366
+ # @param request_pb [::Google::Cloud::Firestore::V1::RunQueryRequest]
367
+ # A request object representing the call parameters. Required.
368
+ # @param options [::Gapic::CallOptions]
369
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
370
+ #
371
+ # @yieldparam chunk [::String] The chunk of data received during server streaming.
372
+ #
373
+ # @return [::Gapic::Rest::TransportOperation]
374
+ def run_query request_pb, options = nil, &block
375
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
376
+
377
+ verb, uri, query_string_params, body = ServiceStub.transcode_run_query_request request_pb
378
+ query_string_params = if query_string_params.any?
379
+ query_string_params.to_h { |p| p.split "=", 2 }
380
+ else
381
+ {}
382
+ end
383
+
384
+ response = @client_stub.make_http_request(
385
+ verb,
386
+ uri: uri,
387
+ body: body || "",
388
+ params: query_string_params,
389
+ options: options,
390
+ is_server_streaming: true,
391
+ &block
392
+ )
393
+ ::Gapic::Rest::TransportOperation.new response
394
+ end
395
+
396
+ ##
397
+ # Baseline implementation for the run_aggregation_query REST call
398
+ #
399
+ # @param request_pb [::Google::Cloud::Firestore::V1::RunAggregationQueryRequest]
400
+ # A request object representing the call parameters. Required.
401
+ # @param options [::Gapic::CallOptions]
402
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
403
+ #
404
+ # @yieldparam chunk [::String] The chunk of data received during server streaming.
405
+ #
406
+ # @return [::Gapic::Rest::TransportOperation]
407
+ def run_aggregation_query request_pb, options = nil, &block
408
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
409
+
410
+ verb, uri, query_string_params, body = ServiceStub.transcode_run_aggregation_query_request request_pb
411
+ query_string_params = if query_string_params.any?
412
+ query_string_params.to_h { |p| p.split "=", 2 }
413
+ else
414
+ {}
415
+ end
416
+
417
+ response = @client_stub.make_http_request(
418
+ verb,
419
+ uri: uri,
420
+ body: body || "",
421
+ params: query_string_params,
422
+ options: options,
423
+ is_server_streaming: true,
424
+ &block
425
+ )
426
+ ::Gapic::Rest::TransportOperation.new response
427
+ end
428
+
429
+ ##
430
+ # Baseline implementation for the partition_query REST call
431
+ #
432
+ # @param request_pb [::Google::Cloud::Firestore::V1::PartitionQueryRequest]
433
+ # A request object representing the call parameters. Required.
434
+ # @param options [::Gapic::CallOptions]
435
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
436
+ #
437
+ # @yield [result, operation] Access the result along with the TransportOperation object
438
+ # @yieldparam result [::Google::Cloud::Firestore::V1::PartitionQueryResponse]
439
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
440
+ #
441
+ # @return [::Google::Cloud::Firestore::V1::PartitionQueryResponse]
442
+ # A result object deserialized from the server's reply
443
+ def partition_query request_pb, options = nil
444
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
445
+
446
+ verb, uri, query_string_params, body = ServiceStub.transcode_partition_query_request request_pb
447
+ query_string_params = if query_string_params.any?
448
+ query_string_params.to_h { |p| p.split "=", 2 }
449
+ else
450
+ {}
451
+ end
452
+
453
+ response = @client_stub.make_http_request(
454
+ verb,
455
+ uri: uri,
456
+ body: body || "",
457
+ params: query_string_params,
458
+ options: options
459
+ )
460
+ operation = ::Gapic::Rest::TransportOperation.new response
461
+ result = ::Google::Cloud::Firestore::V1::PartitionQueryResponse.decode_json response.body, ignore_unknown_fields: true
462
+
463
+ yield result, operation if block_given?
464
+ result
465
+ end
466
+
467
+ ##
468
+ # Baseline implementation for the list_collection_ids REST call
469
+ #
470
+ # @param request_pb [::Google::Cloud::Firestore::V1::ListCollectionIdsRequest]
471
+ # A request object representing the call parameters. Required.
472
+ # @param options [::Gapic::CallOptions]
473
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
474
+ #
475
+ # @yield [result, operation] Access the result along with the TransportOperation object
476
+ # @yieldparam result [::Google::Cloud::Firestore::V1::ListCollectionIdsResponse]
477
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
478
+ #
479
+ # @return [::Google::Cloud::Firestore::V1::ListCollectionIdsResponse]
480
+ # A result object deserialized from the server's reply
481
+ def list_collection_ids request_pb, options = nil
482
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
483
+
484
+ verb, uri, query_string_params, body = ServiceStub.transcode_list_collection_ids_request request_pb
485
+ query_string_params = if query_string_params.any?
486
+ query_string_params.to_h { |p| p.split "=", 2 }
487
+ else
488
+ {}
489
+ end
490
+
491
+ response = @client_stub.make_http_request(
492
+ verb,
493
+ uri: uri,
494
+ body: body || "",
495
+ params: query_string_params,
496
+ options: options
497
+ )
498
+ operation = ::Gapic::Rest::TransportOperation.new response
499
+ result = ::Google::Cloud::Firestore::V1::ListCollectionIdsResponse.decode_json response.body, ignore_unknown_fields: true
500
+
501
+ yield result, operation if block_given?
502
+ result
503
+ end
504
+
505
+ ##
506
+ # Baseline implementation for the batch_write REST call
507
+ #
508
+ # @param request_pb [::Google::Cloud::Firestore::V1::BatchWriteRequest]
509
+ # A request object representing the call parameters. Required.
510
+ # @param options [::Gapic::CallOptions]
511
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
512
+ #
513
+ # @yield [result, operation] Access the result along with the TransportOperation object
514
+ # @yieldparam result [::Google::Cloud::Firestore::V1::BatchWriteResponse]
515
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
516
+ #
517
+ # @return [::Google::Cloud::Firestore::V1::BatchWriteResponse]
518
+ # A result object deserialized from the server's reply
519
+ def batch_write request_pb, options = nil
520
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
521
+
522
+ verb, uri, query_string_params, body = ServiceStub.transcode_batch_write_request request_pb
523
+ query_string_params = if query_string_params.any?
524
+ query_string_params.to_h { |p| p.split "=", 2 }
525
+ else
526
+ {}
527
+ end
528
+
529
+ response = @client_stub.make_http_request(
530
+ verb,
531
+ uri: uri,
532
+ body: body || "",
533
+ params: query_string_params,
534
+ options: options
535
+ )
536
+ operation = ::Gapic::Rest::TransportOperation.new response
537
+ result = ::Google::Cloud::Firestore::V1::BatchWriteResponse.decode_json response.body, ignore_unknown_fields: true
538
+
539
+ yield result, operation if block_given?
540
+ result
541
+ end
542
+
543
+ ##
544
+ # Baseline implementation for the create_document REST call
545
+ #
546
+ # @param request_pb [::Google::Cloud::Firestore::V1::CreateDocumentRequest]
547
+ # A request object representing the call parameters. Required.
548
+ # @param options [::Gapic::CallOptions]
549
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
550
+ #
551
+ # @yield [result, operation] Access the result along with the TransportOperation object
552
+ # @yieldparam result [::Google::Cloud::Firestore::V1::Document]
553
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
554
+ #
555
+ # @return [::Google::Cloud::Firestore::V1::Document]
556
+ # A result object deserialized from the server's reply
557
+ def create_document request_pb, options = nil
558
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
559
+
560
+ verb, uri, query_string_params, body = ServiceStub.transcode_create_document_request request_pb
561
+ query_string_params = if query_string_params.any?
562
+ query_string_params.to_h { |p| p.split "=", 2 }
563
+ else
564
+ {}
565
+ end
566
+
567
+ response = @client_stub.make_http_request(
568
+ verb,
569
+ uri: uri,
570
+ body: body || "",
571
+ params: query_string_params,
572
+ options: options
573
+ )
574
+ operation = ::Gapic::Rest::TransportOperation.new response
575
+ result = ::Google::Cloud::Firestore::V1::Document.decode_json response.body, ignore_unknown_fields: true
576
+
577
+ yield result, operation if block_given?
578
+ result
579
+ end
580
+
581
+ ##
582
+ # @private
583
+ #
584
+ # GRPC transcoding helper method for the get_document REST call
585
+ #
586
+ # @param request_pb [::Google::Cloud::Firestore::V1::GetDocumentRequest]
587
+ # A request object representing the call parameters. Required.
588
+ # @return [Array(String, [String, nil], Hash{String => String})]
589
+ # Uri, Body, Query string parameters
590
+ def self.transcode_get_document_request request_pb
591
+ transcoder = Gapic::Rest::GrpcTranscoder.new
592
+ .with_bindings(
593
+ uri_method: :get,
594
+ uri_template: "/v1/{name}",
595
+ matches: [
596
+ ["name", %r{^projects/[^/]+/databases/[^/]+/documents/[^/]+(?:/.*)?$}, true]
597
+ ]
598
+ )
599
+ transcoder.transcode request_pb
600
+ end
601
+
602
+ ##
603
+ # @private
604
+ #
605
+ # GRPC transcoding helper method for the list_documents REST call
606
+ #
607
+ # @param request_pb [::Google::Cloud::Firestore::V1::ListDocumentsRequest]
608
+ # A request object representing the call parameters. Required.
609
+ # @return [Array(String, [String, nil], Hash{String => String})]
610
+ # Uri, Body, Query string parameters
611
+ def self.transcode_list_documents_request request_pb
612
+ transcoder = Gapic::Rest::GrpcTranscoder.new
613
+ .with_bindings(
614
+ uri_method: :get,
615
+ uri_template: "/v1/{parent}/{collection_id}",
616
+ matches: [
617
+ ["parent", %r{^projects/[^/]+/databases/[^/]+/documents/[^/]+(?:/.*)?$}, true],
618
+ ["collection_id", %r{^[^/]+/?$}, false]
619
+ ]
620
+ )
621
+ .with_bindings(
622
+ uri_method: :get,
623
+ uri_template: "/v1/{parent}/{collection_id}",
624
+ matches: [
625
+ ["parent", %r{^projects/[^/]+/databases/[^/]+/documents/?$}, false],
626
+ ["collection_id", %r{^[^/]+/?$}, false]
627
+ ]
628
+ )
629
+ transcoder.transcode request_pb
630
+ end
631
+
632
+ ##
633
+ # @private
634
+ #
635
+ # GRPC transcoding helper method for the update_document REST call
636
+ #
637
+ # @param request_pb [::Google::Cloud::Firestore::V1::UpdateDocumentRequest]
638
+ # A request object representing the call parameters. Required.
639
+ # @return [Array(String, [String, nil], Hash{String => String})]
640
+ # Uri, Body, Query string parameters
641
+ def self.transcode_update_document_request request_pb
642
+ transcoder = Gapic::Rest::GrpcTranscoder.new
643
+ .with_bindings(
644
+ uri_method: :patch,
645
+ uri_template: "/v1/{document.name}",
646
+ body: "document",
647
+ matches: [
648
+ ["document.name", %r{^projects/[^/]+/databases/[^/]+/documents/[^/]+(?:/.*)?$}, true]
649
+ ]
650
+ )
651
+ transcoder.transcode request_pb
652
+ end
653
+
654
+ ##
655
+ # @private
656
+ #
657
+ # GRPC transcoding helper method for the delete_document REST call
658
+ #
659
+ # @param request_pb [::Google::Cloud::Firestore::V1::DeleteDocumentRequest]
660
+ # A request object representing the call parameters. Required.
661
+ # @return [Array(String, [String, nil], Hash{String => String})]
662
+ # Uri, Body, Query string parameters
663
+ def self.transcode_delete_document_request request_pb
664
+ transcoder = Gapic::Rest::GrpcTranscoder.new
665
+ .with_bindings(
666
+ uri_method: :delete,
667
+ uri_template: "/v1/{name}",
668
+ matches: [
669
+ ["name", %r{^projects/[^/]+/databases/[^/]+/documents/[^/]+(?:/.*)?$}, true]
670
+ ]
671
+ )
672
+ transcoder.transcode request_pb
673
+ end
674
+
675
+ ##
676
+ # @private
677
+ #
678
+ # GRPC transcoding helper method for the batch_get_documents REST call
679
+ #
680
+ # @param request_pb [::Google::Cloud::Firestore::V1::BatchGetDocumentsRequest]
681
+ # A request object representing the call parameters. Required.
682
+ # @return [Array(String, [String, nil], Hash{String => String})]
683
+ # Uri, Body, Query string parameters
684
+ def self.transcode_batch_get_documents_request request_pb
685
+ transcoder = Gapic::Rest::GrpcTranscoder.new
686
+ .with_bindings(
687
+ uri_method: :post,
688
+ uri_template: "/v1/{database}/documents:batchGet",
689
+ body: "*",
690
+ matches: [
691
+ ["database", %r{^projects/[^/]+/databases/[^/]+/?$}, false]
692
+ ]
693
+ )
694
+ transcoder.transcode request_pb
695
+ end
696
+
697
+ ##
698
+ # @private
699
+ #
700
+ # GRPC transcoding helper method for the begin_transaction REST call
701
+ #
702
+ # @param request_pb [::Google::Cloud::Firestore::V1::BeginTransactionRequest]
703
+ # A request object representing the call parameters. Required.
704
+ # @return [Array(String, [String, nil], Hash{String => String})]
705
+ # Uri, Body, Query string parameters
706
+ def self.transcode_begin_transaction_request request_pb
707
+ transcoder = Gapic::Rest::GrpcTranscoder.new
708
+ .with_bindings(
709
+ uri_method: :post,
710
+ uri_template: "/v1/{database}/documents:beginTransaction",
711
+ body: "*",
712
+ matches: [
713
+ ["database", %r{^projects/[^/]+/databases/[^/]+/?$}, false]
714
+ ]
715
+ )
716
+ transcoder.transcode request_pb
717
+ end
718
+
719
+ ##
720
+ # @private
721
+ #
722
+ # GRPC transcoding helper method for the commit REST call
723
+ #
724
+ # @param request_pb [::Google::Cloud::Firestore::V1::CommitRequest]
725
+ # A request object representing the call parameters. Required.
726
+ # @return [Array(String, [String, nil], Hash{String => String})]
727
+ # Uri, Body, Query string parameters
728
+ def self.transcode_commit_request request_pb
729
+ transcoder = Gapic::Rest::GrpcTranscoder.new
730
+ .with_bindings(
731
+ uri_method: :post,
732
+ uri_template: "/v1/{database}/documents:commit",
733
+ body: "*",
734
+ matches: [
735
+ ["database", %r{^projects/[^/]+/databases/[^/]+/?$}, false]
736
+ ]
737
+ )
738
+ transcoder.transcode request_pb
739
+ end
740
+
741
+ ##
742
+ # @private
743
+ #
744
+ # GRPC transcoding helper method for the rollback REST call
745
+ #
746
+ # @param request_pb [::Google::Cloud::Firestore::V1::RollbackRequest]
747
+ # A request object representing the call parameters. Required.
748
+ # @return [Array(String, [String, nil], Hash{String => String})]
749
+ # Uri, Body, Query string parameters
750
+ def self.transcode_rollback_request request_pb
751
+ transcoder = Gapic::Rest::GrpcTranscoder.new
752
+ .with_bindings(
753
+ uri_method: :post,
754
+ uri_template: "/v1/{database}/documents:rollback",
755
+ body: "*",
756
+ matches: [
757
+ ["database", %r{^projects/[^/]+/databases/[^/]+/?$}, false]
758
+ ]
759
+ )
760
+ transcoder.transcode request_pb
761
+ end
762
+
763
+ ##
764
+ # @private
765
+ #
766
+ # GRPC transcoding helper method for the run_query REST call
767
+ #
768
+ # @param request_pb [::Google::Cloud::Firestore::V1::RunQueryRequest]
769
+ # A request object representing the call parameters. Required.
770
+ # @return [Array(String, [String, nil], Hash{String => String})]
771
+ # Uri, Body, Query string parameters
772
+ def self.transcode_run_query_request request_pb
773
+ transcoder = Gapic::Rest::GrpcTranscoder.new
774
+ .with_bindings(
775
+ uri_method: :post,
776
+ uri_template: "/v1/{parent}:runQuery",
777
+ body: "*",
778
+ matches: [
779
+ ["parent", %r{^projects/[^/]+/databases/[^/]+/documents/?$}, false]
780
+ ]
781
+ )
782
+ .with_bindings(
783
+ uri_method: :post,
784
+ uri_template: "/v1/{parent}:runQuery",
785
+ body: "*",
786
+ matches: [
787
+ ["parent", %r{^projects/[^/]+/databases/[^/]+/documents/[^/]+(?:/.*)?$}, true]
788
+ ]
789
+ )
790
+ transcoder.transcode request_pb
791
+ end
792
+
793
+ ##
794
+ # @private
795
+ #
796
+ # GRPC transcoding helper method for the run_aggregation_query REST call
797
+ #
798
+ # @param request_pb [::Google::Cloud::Firestore::V1::RunAggregationQueryRequest]
799
+ # A request object representing the call parameters. Required.
800
+ # @return [Array(String, [String, nil], Hash{String => String})]
801
+ # Uri, Body, Query string parameters
802
+ def self.transcode_run_aggregation_query_request request_pb
803
+ transcoder = Gapic::Rest::GrpcTranscoder.new
804
+ .with_bindings(
805
+ uri_method: :post,
806
+ uri_template: "/v1/{parent}:runAggregationQuery",
807
+ body: "*",
808
+ matches: [
809
+ ["parent", %r{^projects/[^/]+/databases/[^/]+/documents/?$}, false]
810
+ ]
811
+ )
812
+ .with_bindings(
813
+ uri_method: :post,
814
+ uri_template: "/v1/{parent}:runAggregationQuery",
815
+ body: "*",
816
+ matches: [
817
+ ["parent", %r{^projects/[^/]+/databases/[^/]+/documents/[^/]+(?:/.*)?$}, true]
818
+ ]
819
+ )
820
+ transcoder.transcode request_pb
821
+ end
822
+
823
+ ##
824
+ # @private
825
+ #
826
+ # GRPC transcoding helper method for the partition_query REST call
827
+ #
828
+ # @param request_pb [::Google::Cloud::Firestore::V1::PartitionQueryRequest]
829
+ # A request object representing the call parameters. Required.
830
+ # @return [Array(String, [String, nil], Hash{String => String})]
831
+ # Uri, Body, Query string parameters
832
+ def self.transcode_partition_query_request request_pb
833
+ transcoder = Gapic::Rest::GrpcTranscoder.new
834
+ .with_bindings(
835
+ uri_method: :post,
836
+ uri_template: "/v1/{parent}:partitionQuery",
837
+ body: "*",
838
+ matches: [
839
+ ["parent", %r{^projects/[^/]+/databases/[^/]+/documents/?$}, false]
840
+ ]
841
+ )
842
+ .with_bindings(
843
+ uri_method: :post,
844
+ uri_template: "/v1/{parent}:partitionQuery",
845
+ body: "*",
846
+ matches: [
847
+ ["parent", %r{^projects/[^/]+/databases/[^/]+/documents/[^/]+(?:/.*)?$}, true]
848
+ ]
849
+ )
850
+ transcoder.transcode request_pb
851
+ end
852
+
853
+ ##
854
+ # @private
855
+ #
856
+ # GRPC transcoding helper method for the list_collection_ids REST call
857
+ #
858
+ # @param request_pb [::Google::Cloud::Firestore::V1::ListCollectionIdsRequest]
859
+ # A request object representing the call parameters. Required.
860
+ # @return [Array(String, [String, nil], Hash{String => String})]
861
+ # Uri, Body, Query string parameters
862
+ def self.transcode_list_collection_ids_request request_pb
863
+ transcoder = Gapic::Rest::GrpcTranscoder.new
864
+ .with_bindings(
865
+ uri_method: :post,
866
+ uri_template: "/v1/{parent}:listCollectionIds",
867
+ body: "*",
868
+ matches: [
869
+ ["parent", %r{^projects/[^/]+/databases/[^/]+/documents/?$}, false]
870
+ ]
871
+ )
872
+ .with_bindings(
873
+ uri_method: :post,
874
+ uri_template: "/v1/{parent}:listCollectionIds",
875
+ body: "*",
876
+ matches: [
877
+ ["parent", %r{^projects/[^/]+/databases/[^/]+/documents/[^/]+(?:/.*)?$}, true]
878
+ ]
879
+ )
880
+ transcoder.transcode request_pb
881
+ end
882
+
883
+ ##
884
+ # @private
885
+ #
886
+ # GRPC transcoding helper method for the batch_write REST call
887
+ #
888
+ # @param request_pb [::Google::Cloud::Firestore::V1::BatchWriteRequest]
889
+ # A request object representing the call parameters. Required.
890
+ # @return [Array(String, [String, nil], Hash{String => String})]
891
+ # Uri, Body, Query string parameters
892
+ def self.transcode_batch_write_request request_pb
893
+ transcoder = Gapic::Rest::GrpcTranscoder.new
894
+ .with_bindings(
895
+ uri_method: :post,
896
+ uri_template: "/v1/{database}/documents:batchWrite",
897
+ body: "*",
898
+ matches: [
899
+ ["database", %r{^projects/[^/]+/databases/[^/]+/?$}, false]
900
+ ]
901
+ )
902
+ transcoder.transcode request_pb
903
+ end
904
+
905
+ ##
906
+ # @private
907
+ #
908
+ # GRPC transcoding helper method for the create_document REST call
909
+ #
910
+ # @param request_pb [::Google::Cloud::Firestore::V1::CreateDocumentRequest]
911
+ # A request object representing the call parameters. Required.
912
+ # @return [Array(String, [String, nil], Hash{String => String})]
913
+ # Uri, Body, Query string parameters
914
+ def self.transcode_create_document_request request_pb
915
+ transcoder = Gapic::Rest::GrpcTranscoder.new
916
+ .with_bindings(
917
+ uri_method: :post,
918
+ uri_template: "/v1/{parent}/{collection_id}",
919
+ body: "document",
920
+ matches: [
921
+ ["parent", %r{^projects/[^/]+/databases/[^/]+/documents(?:/.*)?$}, true],
922
+ ["collection_id", %r{^[^/]+/?$}, false]
923
+ ]
924
+ )
925
+ transcoder.transcode request_pb
926
+ end
927
+ end
928
+ end
929
+ end
930
+ end
931
+ end
932
+ end
933
+ end