google-cloud-firestore-v1 0.8.0 → 0.10.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.
@@ -0,0 +1,1600 @@
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/cloud/errors"
20
+ require "google/firestore/v1/firestore_pb"
21
+ require "google/cloud/firestore/v1/firestore/rest/service_stub"
22
+ require "google/cloud/location/rest"
23
+
24
+ module Google
25
+ module Cloud
26
+ module Firestore
27
+ module V1
28
+ module Firestore
29
+ module Rest
30
+ ##
31
+ # REST client for the Firestore service.
32
+ #
33
+ # The Cloud Firestore service.
34
+ #
35
+ # Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL
36
+ # document database that simplifies storing, syncing, and querying data for
37
+ # your mobile, web, and IoT apps at global scale. Its client libraries provide
38
+ # live synchronization and offline support, while its security features and
39
+ # integrations with Firebase and Google Cloud Platform accelerate building
40
+ # truly serverless apps.
41
+ #
42
+ class Client
43
+ # @private
44
+ attr_reader :firestore_stub
45
+
46
+ ##
47
+ # Configure the Firestore Client class.
48
+ #
49
+ # See {::Google::Cloud::Firestore::V1::Firestore::Rest::Client::Configuration}
50
+ # for a description of the configuration fields.
51
+ #
52
+ # @example
53
+ #
54
+ # # Modify the configuration for all Firestore clients
55
+ # ::Google::Cloud::Firestore::V1::Firestore::Rest::Client.configure do |config|
56
+ # config.timeout = 10.0
57
+ # end
58
+ #
59
+ # @yield [config] Configure the Client client.
60
+ # @yieldparam config [Client::Configuration]
61
+ #
62
+ # @return [Client::Configuration]
63
+ #
64
+ def self.configure
65
+ @configure ||= begin
66
+ namespace = ["Google", "Cloud", "Firestore", "V1"]
67
+ parent_config = while namespace.any?
68
+ parent_name = namespace.join "::"
69
+ parent_const = const_get parent_name
70
+ break parent_const.configure if parent_const.respond_to? :configure
71
+ namespace.pop
72
+ end
73
+ default_config = Client::Configuration.new parent_config
74
+
75
+ default_config.rpcs.get_document.timeout = 60.0
76
+ default_config.rpcs.get_document.retry_policy = {
77
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4]
78
+ }
79
+
80
+ default_config.rpcs.list_documents.timeout = 60.0
81
+ default_config.rpcs.list_documents.retry_policy = {
82
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4]
83
+ }
84
+
85
+ default_config.rpcs.update_document.timeout = 60.0
86
+ default_config.rpcs.update_document.retry_policy = {
87
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14]
88
+ }
89
+
90
+ default_config.rpcs.delete_document.timeout = 60.0
91
+ default_config.rpcs.delete_document.retry_policy = {
92
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4]
93
+ }
94
+
95
+ default_config.rpcs.batch_get_documents.timeout = 300.0
96
+ default_config.rpcs.batch_get_documents.retry_policy = {
97
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4]
98
+ }
99
+
100
+ default_config.rpcs.begin_transaction.timeout = 60.0
101
+ default_config.rpcs.begin_transaction.retry_policy = {
102
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4]
103
+ }
104
+
105
+ default_config.rpcs.commit.timeout = 60.0
106
+ default_config.rpcs.commit.retry_policy = {
107
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14]
108
+ }
109
+
110
+ default_config.rpcs.rollback.timeout = 60.0
111
+ default_config.rpcs.rollback.retry_policy = {
112
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4]
113
+ }
114
+
115
+ default_config.rpcs.run_query.timeout = 300.0
116
+ default_config.rpcs.run_query.retry_policy = {
117
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4]
118
+ }
119
+
120
+ default_config.rpcs.run_aggregation_query.timeout = 300.0
121
+ default_config.rpcs.run_aggregation_query.retry_policy = {
122
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4]
123
+ }
124
+
125
+ default_config.rpcs.partition_query.timeout = 300.0
126
+ default_config.rpcs.partition_query.retry_policy = {
127
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4]
128
+ }
129
+
130
+ default_config.rpcs.list_collection_ids.timeout = 60.0
131
+ default_config.rpcs.list_collection_ids.retry_policy = {
132
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4]
133
+ }
134
+
135
+ default_config.rpcs.batch_write.timeout = 60.0
136
+ default_config.rpcs.batch_write.retry_policy = {
137
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 10]
138
+ }
139
+
140
+ default_config.rpcs.create_document.timeout = 60.0
141
+ default_config.rpcs.create_document.retry_policy = {
142
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14]
143
+ }
144
+
145
+ default_config
146
+ end
147
+ yield @configure if block_given?
148
+ @configure
149
+ end
150
+
151
+ ##
152
+ # Configure the Firestore Client instance.
153
+ #
154
+ # The configuration is set to the derived mode, meaning that values can be changed,
155
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
156
+ # should be made on {Client.configure}.
157
+ #
158
+ # See {::Google::Cloud::Firestore::V1::Firestore::Rest::Client::Configuration}
159
+ # for a description of the configuration fields.
160
+ #
161
+ # @yield [config] Configure the Client client.
162
+ # @yieldparam config [Client::Configuration]
163
+ #
164
+ # @return [Client::Configuration]
165
+ #
166
+ def configure
167
+ yield @config if block_given?
168
+ @config
169
+ end
170
+
171
+ ##
172
+ # Create a new Firestore REST client object.
173
+ #
174
+ # @example
175
+ #
176
+ # # Create a client using the default configuration
177
+ # client = ::Google::Cloud::Firestore::V1::Firestore::Rest::Client.new
178
+ #
179
+ # # Create a client using a custom configuration
180
+ # client = ::Google::Cloud::Firestore::V1::Firestore::Rest::Client.new do |config|
181
+ # config.timeout = 10.0
182
+ # end
183
+ #
184
+ # @yield [config] Configure the Firestore client.
185
+ # @yieldparam config [Client::Configuration]
186
+ #
187
+ def initialize
188
+ # Create the configuration object
189
+ @config = Configuration.new Client.configure
190
+
191
+ # Yield the configuration if needed
192
+ yield @config if block_given?
193
+
194
+ # Create credentials
195
+ credentials = @config.credentials
196
+ # Use self-signed JWT if the endpoint is unchanged from default,
197
+ # but only if the default endpoint does not have a region prefix.
198
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
199
+ !@config.endpoint.split(".").first.include?("-")
200
+ credentials ||= Credentials.default scope: @config.scope,
201
+ enable_self_signed_jwt: enable_self_signed_jwt
202
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
203
+ credentials = Credentials.new credentials, scope: @config.scope
204
+ end
205
+
206
+ @quota_project_id = @config.quota_project
207
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
208
+
209
+ @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
210
+ config.credentials = credentials
211
+ config.quota_project = @quota_project_id
212
+ config.endpoint = @config.endpoint
213
+ end
214
+
215
+ @firestore_stub = ::Google::Cloud::Firestore::V1::Firestore::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
216
+ end
217
+
218
+ ##
219
+ # Get the associated client for mix-in of the Locations.
220
+ #
221
+ # @return [Google::Cloud::Location::Locations::Rest::Client]
222
+ #
223
+ attr_reader :location_client
224
+
225
+ # Service calls
226
+
227
+ ##
228
+ # Gets a single document.
229
+ #
230
+ # @overload get_document(request, options = nil)
231
+ # Pass arguments to `get_document` via a request object, either of type
232
+ # {::Google::Cloud::Firestore::V1::GetDocumentRequest} or an equivalent Hash.
233
+ #
234
+ # @param request [::Google::Cloud::Firestore::V1::GetDocumentRequest, ::Hash]
235
+ # A request object representing the call parameters. Required. To specify no
236
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
237
+ # @param options [::Gapic::CallOptions, ::Hash]
238
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
239
+ #
240
+ # @overload get_document(name: nil, mask: nil, transaction: nil, read_time: nil)
241
+ # Pass arguments to `get_document` via keyword arguments. Note that at
242
+ # least one keyword argument is required. To specify no parameters, or to keep all
243
+ # the default parameter values, pass an empty Hash as a request object (see above).
244
+ #
245
+ # @param name [::String]
246
+ # Required. The resource name of the Document to get. In the format:
247
+ # `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
248
+ # @param mask [::Google::Cloud::Firestore::V1::DocumentMask, ::Hash]
249
+ # The fields to return. If not set, returns all fields.
250
+ #
251
+ # If the document has a field that is not present in this mask, that field
252
+ # will not be returned in the response.
253
+ # @param transaction [::String]
254
+ # Reads the document in a transaction.
255
+ # @param read_time [::Google::Protobuf::Timestamp, ::Hash]
256
+ # Reads the version of the document at the given time.
257
+ # This may not be older than 270 seconds.
258
+ # @yield [result, operation] Access the result along with the TransportOperation object
259
+ # @yieldparam result [::Google::Cloud::Firestore::V1::Document]
260
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
261
+ #
262
+ # @return [::Google::Cloud::Firestore::V1::Document]
263
+ #
264
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
265
+ def get_document request, options = nil
266
+ raise ::ArgumentError, "request must be provided" if request.nil?
267
+
268
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::GetDocumentRequest
269
+
270
+ # Converts hash and nil to an options object
271
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
272
+
273
+ # Customize the options with defaults
274
+ call_metadata = @config.rpcs.get_document.metadata.to_h
275
+
276
+ # Set x-goog-api-client and x-goog-user-project headers
277
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
278
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
279
+ gapic_version: ::Google::Cloud::Firestore::V1::VERSION,
280
+ transports_version_send: [:rest]
281
+
282
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
283
+
284
+ options.apply_defaults timeout: @config.rpcs.get_document.timeout,
285
+ metadata: call_metadata,
286
+ retry_policy: @config.rpcs.get_document.retry_policy
287
+
288
+ options.apply_defaults timeout: @config.timeout,
289
+ metadata: @config.metadata,
290
+ retry_policy: @config.retry_policy
291
+
292
+ @firestore_stub.get_document request, options do |result, operation|
293
+ yield result, operation if block_given?
294
+ return result
295
+ end
296
+ rescue ::Gapic::Rest::Error => e
297
+ raise ::Google::Cloud::Error.from_error(e)
298
+ end
299
+
300
+ ##
301
+ # Lists documents.
302
+ #
303
+ # @overload list_documents(request, options = nil)
304
+ # Pass arguments to `list_documents` via a request object, either of type
305
+ # {::Google::Cloud::Firestore::V1::ListDocumentsRequest} or an equivalent Hash.
306
+ #
307
+ # @param request [::Google::Cloud::Firestore::V1::ListDocumentsRequest, ::Hash]
308
+ # A request object representing the call parameters. Required. To specify no
309
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
310
+ # @param options [::Gapic::CallOptions, ::Hash]
311
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
312
+ #
313
+ # @overload list_documents(parent: nil, collection_id: nil, page_size: nil, page_token: nil, order_by: nil, mask: nil, transaction: nil, read_time: nil, show_missing: nil)
314
+ # Pass arguments to `list_documents` via keyword arguments. Note that at
315
+ # least one keyword argument is required. To specify no parameters, or to keep all
316
+ # the default parameter values, pass an empty Hash as a request object (see above).
317
+ #
318
+ # @param parent [::String]
319
+ # Required. The parent resource name. In the format:
320
+ # `projects/{project_id}/databases/{database_id}/documents` or
321
+ # `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
322
+ #
323
+ # For example:
324
+ # `projects/my-project/databases/my-database/documents` or
325
+ # `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
326
+ # @param collection_id [::String]
327
+ # Optional. The collection ID, relative to `parent`, to list.
328
+ #
329
+ # For example: `chatrooms` or `messages`.
330
+ #
331
+ # This is optional, and when not provided, Firestore will list documents
332
+ # from all collections under the provided `parent`.
333
+ # @param page_size [::Integer]
334
+ # Optional. The maximum number of documents to return in a single response.
335
+ #
336
+ # Firestore may return fewer than this value.
337
+ # @param page_token [::String]
338
+ # Optional. A page token, received from a previous `ListDocuments` response.
339
+ #
340
+ # Provide this to retrieve the subsequent page. When paginating, all other
341
+ # parameters (with the exception of `page_size`) must match the values set
342
+ # in the request that generated the page token.
343
+ # @param order_by [::String]
344
+ # Optional. The optional ordering of the documents to return.
345
+ #
346
+ # For example: `priority desc, __name__ desc`.
347
+ #
348
+ # This mirrors the {::Google::Cloud::Firestore::V1::StructuredQuery#order_by `ORDER BY`}
349
+ # used in Firestore queries but in a string representation. When absent,
350
+ # documents are ordered based on `__name__ ASC`.
351
+ # @param mask [::Google::Cloud::Firestore::V1::DocumentMask, ::Hash]
352
+ # Optional. The fields to return. If not set, returns all fields.
353
+ #
354
+ # If a document has a field that is not present in this mask, that field
355
+ # will not be returned in the response.
356
+ # @param transaction [::String]
357
+ # Perform the read as part of an already active transaction.
358
+ # @param read_time [::Google::Protobuf::Timestamp, ::Hash]
359
+ # Perform the read at the provided time.
360
+ #
361
+ # This may not be older than 270 seconds.
362
+ # @param show_missing [::Boolean]
363
+ # If the list should show missing documents.
364
+ #
365
+ # A document is missing if it does not exist, but there are sub-documents
366
+ # nested underneath it. When true, such missing documents will be returned
367
+ # with a key but will not have fields,
368
+ # {::Google::Cloud::Firestore::V1::Document#create_time `create_time`}, or
369
+ # {::Google::Cloud::Firestore::V1::Document#update_time `update_time`} set.
370
+ #
371
+ # Requests with `show_missing` may not specify `where` or `order_by`.
372
+ # @yield [result, operation] Access the result along with the TransportOperation object
373
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Firestore::V1::Document>]
374
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
375
+ #
376
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Firestore::V1::Document>]
377
+ #
378
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
379
+ def list_documents request, options = nil
380
+ raise ::ArgumentError, "request must be provided" if request.nil?
381
+
382
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::ListDocumentsRequest
383
+
384
+ # Converts hash and nil to an options object
385
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
386
+
387
+ # Customize the options with defaults
388
+ call_metadata = @config.rpcs.list_documents.metadata.to_h
389
+
390
+ # Set x-goog-api-client and x-goog-user-project headers
391
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
392
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
393
+ gapic_version: ::Google::Cloud::Firestore::V1::VERSION,
394
+ transports_version_send: [:rest]
395
+
396
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
397
+
398
+ options.apply_defaults timeout: @config.rpcs.list_documents.timeout,
399
+ metadata: call_metadata,
400
+ retry_policy: @config.rpcs.list_documents.retry_policy
401
+
402
+ options.apply_defaults timeout: @config.timeout,
403
+ metadata: @config.metadata,
404
+ retry_policy: @config.retry_policy
405
+
406
+ @firestore_stub.list_documents request, options do |result, operation|
407
+ result = ::Gapic::Rest::PagedEnumerable.new @firestore_stub, :list_documents, "documents", request, result, options
408
+ yield result, operation if block_given?
409
+ return result
410
+ end
411
+ rescue ::Gapic::Rest::Error => e
412
+ raise ::Google::Cloud::Error.from_error(e)
413
+ end
414
+
415
+ ##
416
+ # Updates or inserts a document.
417
+ #
418
+ # @overload update_document(request, options = nil)
419
+ # Pass arguments to `update_document` via a request object, either of type
420
+ # {::Google::Cloud::Firestore::V1::UpdateDocumentRequest} or an equivalent Hash.
421
+ #
422
+ # @param request [::Google::Cloud::Firestore::V1::UpdateDocumentRequest, ::Hash]
423
+ # A request object representing the call parameters. Required. To specify no
424
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
425
+ # @param options [::Gapic::CallOptions, ::Hash]
426
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
427
+ #
428
+ # @overload update_document(document: nil, update_mask: nil, mask: nil, current_document: nil)
429
+ # Pass arguments to `update_document` via keyword arguments. Note that at
430
+ # least one keyword argument is required. To specify no parameters, or to keep all
431
+ # the default parameter values, pass an empty Hash as a request object (see above).
432
+ #
433
+ # @param document [::Google::Cloud::Firestore::V1::Document, ::Hash]
434
+ # Required. The updated document.
435
+ # Creates the document if it does not already exist.
436
+ # @param update_mask [::Google::Cloud::Firestore::V1::DocumentMask, ::Hash]
437
+ # The fields to update.
438
+ # None of the field paths in the mask may contain a reserved name.
439
+ #
440
+ # If the document exists on the server and has fields not referenced in the
441
+ # mask, they are left unchanged.
442
+ # Fields referenced in the mask, but not present in the input document, are
443
+ # deleted from the document on the server.
444
+ # @param mask [::Google::Cloud::Firestore::V1::DocumentMask, ::Hash]
445
+ # The fields to return. If not set, returns all fields.
446
+ #
447
+ # If the document has a field that is not present in this mask, that field
448
+ # will not be returned in the response.
449
+ # @param current_document [::Google::Cloud::Firestore::V1::Precondition, ::Hash]
450
+ # An optional precondition on the document.
451
+ # The request will fail if this is set and not met by the target document.
452
+ # @yield [result, operation] Access the result along with the TransportOperation object
453
+ # @yieldparam result [::Google::Cloud::Firestore::V1::Document]
454
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
455
+ #
456
+ # @return [::Google::Cloud::Firestore::V1::Document]
457
+ #
458
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
459
+ def update_document request, options = nil
460
+ raise ::ArgumentError, "request must be provided" if request.nil?
461
+
462
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::UpdateDocumentRequest
463
+
464
+ # Converts hash and nil to an options object
465
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
466
+
467
+ # Customize the options with defaults
468
+ call_metadata = @config.rpcs.update_document.metadata.to_h
469
+
470
+ # Set x-goog-api-client and x-goog-user-project headers
471
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
472
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
473
+ gapic_version: ::Google::Cloud::Firestore::V1::VERSION,
474
+ transports_version_send: [:rest]
475
+
476
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
477
+
478
+ options.apply_defaults timeout: @config.rpcs.update_document.timeout,
479
+ metadata: call_metadata,
480
+ retry_policy: @config.rpcs.update_document.retry_policy
481
+
482
+ options.apply_defaults timeout: @config.timeout,
483
+ metadata: @config.metadata,
484
+ retry_policy: @config.retry_policy
485
+
486
+ @firestore_stub.update_document request, options do |result, operation|
487
+ yield result, operation if block_given?
488
+ return result
489
+ end
490
+ rescue ::Gapic::Rest::Error => e
491
+ raise ::Google::Cloud::Error.from_error(e)
492
+ end
493
+
494
+ ##
495
+ # Deletes a document.
496
+ #
497
+ # @overload delete_document(request, options = nil)
498
+ # Pass arguments to `delete_document` via a request object, either of type
499
+ # {::Google::Cloud::Firestore::V1::DeleteDocumentRequest} or an equivalent Hash.
500
+ #
501
+ # @param request [::Google::Cloud::Firestore::V1::DeleteDocumentRequest, ::Hash]
502
+ # A request object representing the call parameters. Required. To specify no
503
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
504
+ # @param options [::Gapic::CallOptions, ::Hash]
505
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
506
+ #
507
+ # @overload delete_document(name: nil, current_document: nil)
508
+ # Pass arguments to `delete_document` via keyword arguments. Note that at
509
+ # least one keyword argument is required. To specify no parameters, or to keep all
510
+ # the default parameter values, pass an empty Hash as a request object (see above).
511
+ #
512
+ # @param name [::String]
513
+ # Required. The resource name of the Document to delete. In the format:
514
+ # `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
515
+ # @param current_document [::Google::Cloud::Firestore::V1::Precondition, ::Hash]
516
+ # An optional precondition on the document.
517
+ # The request will fail if this is set and not met by the target document.
518
+ # @yield [result, operation] Access the result along with the TransportOperation object
519
+ # @yieldparam result [::Google::Protobuf::Empty]
520
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
521
+ #
522
+ # @return [::Google::Protobuf::Empty]
523
+ #
524
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
525
+ def delete_document request, options = nil
526
+ raise ::ArgumentError, "request must be provided" if request.nil?
527
+
528
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::DeleteDocumentRequest
529
+
530
+ # Converts hash and nil to an options object
531
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
532
+
533
+ # Customize the options with defaults
534
+ call_metadata = @config.rpcs.delete_document.metadata.to_h
535
+
536
+ # Set x-goog-api-client and x-goog-user-project headers
537
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
538
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
539
+ gapic_version: ::Google::Cloud::Firestore::V1::VERSION,
540
+ transports_version_send: [:rest]
541
+
542
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
543
+
544
+ options.apply_defaults timeout: @config.rpcs.delete_document.timeout,
545
+ metadata: call_metadata,
546
+ retry_policy: @config.rpcs.delete_document.retry_policy
547
+
548
+ options.apply_defaults timeout: @config.timeout,
549
+ metadata: @config.metadata,
550
+ retry_policy: @config.retry_policy
551
+
552
+ @firestore_stub.delete_document request, options do |result, operation|
553
+ yield result, operation if block_given?
554
+ return result
555
+ end
556
+ rescue ::Gapic::Rest::Error => e
557
+ raise ::Google::Cloud::Error.from_error(e)
558
+ end
559
+
560
+ ##
561
+ # Gets multiple documents.
562
+ #
563
+ # Documents returned by this method are not guaranteed to be returned in the
564
+ # same order that they were requested.
565
+ #
566
+ # @overload batch_get_documents(request, options = nil)
567
+ # Pass arguments to `batch_get_documents` via a request object, either of type
568
+ # {::Google::Cloud::Firestore::V1::BatchGetDocumentsRequest} or an equivalent Hash.
569
+ #
570
+ # @param request [::Google::Cloud::Firestore::V1::BatchGetDocumentsRequest, ::Hash]
571
+ # A request object representing the call parameters. Required. To specify no
572
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
573
+ # @param options [::Gapic::CallOptions, ::Hash]
574
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
575
+ #
576
+ # @overload batch_get_documents(database: nil, documents: nil, mask: nil, transaction: nil, new_transaction: nil, read_time: nil)
577
+ # Pass arguments to `batch_get_documents` via keyword arguments. Note that at
578
+ # least one keyword argument is required. To specify no parameters, or to keep all
579
+ # the default parameter values, pass an empty Hash as a request object (see above).
580
+ #
581
+ # @param database [::String]
582
+ # Required. The database name. In the format:
583
+ # `projects/{project_id}/databases/{database_id}`.
584
+ # @param documents [::Array<::String>]
585
+ # The names of the documents to retrieve. In the format:
586
+ # `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
587
+ # The request will fail if any of the document is not a child resource of the
588
+ # given `database`. Duplicate names will be elided.
589
+ # @param mask [::Google::Cloud::Firestore::V1::DocumentMask, ::Hash]
590
+ # The fields to return. If not set, returns all fields.
591
+ #
592
+ # If a document has a field that is not present in this mask, that field will
593
+ # not be returned in the response.
594
+ # @param transaction [::String]
595
+ # Reads documents in a transaction.
596
+ # @param new_transaction [::Google::Cloud::Firestore::V1::TransactionOptions, ::Hash]
597
+ # Starts a new transaction and reads the documents.
598
+ # Defaults to a read-only transaction.
599
+ # The new transaction ID will be returned as the first response in the
600
+ # stream.
601
+ # @param read_time [::Google::Protobuf::Timestamp, ::Hash]
602
+ # Reads documents as they were at the given time.
603
+ # This may not be older than 270 seconds.
604
+ # @return [::Enumerable<::Google::Cloud::Firestore::V1::BatchGetDocumentsResponse>]
605
+ #
606
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
607
+ def batch_get_documents request, options = nil
608
+ raise ::ArgumentError, "request must be provided" if request.nil?
609
+
610
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::BatchGetDocumentsRequest
611
+
612
+ # Converts hash and nil to an options object
613
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
614
+
615
+ # Customize the options with defaults
616
+ call_metadata = @config.rpcs.batch_get_documents.metadata.to_h
617
+
618
+ # Set x-goog-api-client and x-goog-user-project headers
619
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
620
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
621
+ gapic_version: ::Google::Cloud::Firestore::V1::VERSION,
622
+ transports_version_send: [:rest]
623
+
624
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
625
+
626
+ options.apply_defaults timeout: @config.rpcs.batch_get_documents.timeout,
627
+ metadata: call_metadata,
628
+ retry_policy: @config.rpcs.batch_get_documents.retry_policy
629
+
630
+ options.apply_defaults timeout: @config.timeout,
631
+ metadata: @config.metadata,
632
+ retry_policy: @config.retry_policy
633
+
634
+ ::Gapic::Rest::ServerStream.new(
635
+ ::Google::Cloud::Firestore::V1::BatchGetDocumentsResponse,
636
+ ::Gapic::Rest::ThreadedEnumerator.new do |in_q, out_q|
637
+ @firestore_stub.batch_get_documents request, options do |chunk|
638
+ in_q.deq
639
+ out_q.enq chunk
640
+ end
641
+ end
642
+ )
643
+ rescue ::Gapic::Rest::Error => e
644
+ raise ::Google::Cloud::Error.from_error(e)
645
+ end
646
+
647
+ ##
648
+ # Starts a new transaction.
649
+ #
650
+ # @overload begin_transaction(request, options = nil)
651
+ # Pass arguments to `begin_transaction` via a request object, either of type
652
+ # {::Google::Cloud::Firestore::V1::BeginTransactionRequest} or an equivalent Hash.
653
+ #
654
+ # @param request [::Google::Cloud::Firestore::V1::BeginTransactionRequest, ::Hash]
655
+ # A request object representing the call parameters. Required. To specify no
656
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
657
+ # @param options [::Gapic::CallOptions, ::Hash]
658
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
659
+ #
660
+ # @overload begin_transaction(database: nil, options: nil)
661
+ # Pass arguments to `begin_transaction` via keyword arguments. Note that at
662
+ # least one keyword argument is required. To specify no parameters, or to keep all
663
+ # the default parameter values, pass an empty Hash as a request object (see above).
664
+ #
665
+ # @param database [::String]
666
+ # Required. The database name. In the format:
667
+ # `projects/{project_id}/databases/{database_id}`.
668
+ # @param options [::Google::Cloud::Firestore::V1::TransactionOptions, ::Hash]
669
+ # The options for the transaction.
670
+ # Defaults to a read-write transaction.
671
+ # @yield [result, operation] Access the result along with the TransportOperation object
672
+ # @yieldparam result [::Google::Cloud::Firestore::V1::BeginTransactionResponse]
673
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
674
+ #
675
+ # @return [::Google::Cloud::Firestore::V1::BeginTransactionResponse]
676
+ #
677
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
678
+ def begin_transaction request, options = nil
679
+ raise ::ArgumentError, "request must be provided" if request.nil?
680
+
681
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::BeginTransactionRequest
682
+
683
+ # Converts hash and nil to an options object
684
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
685
+
686
+ # Customize the options with defaults
687
+ call_metadata = @config.rpcs.begin_transaction.metadata.to_h
688
+
689
+ # Set x-goog-api-client and x-goog-user-project headers
690
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
691
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
692
+ gapic_version: ::Google::Cloud::Firestore::V1::VERSION,
693
+ transports_version_send: [:rest]
694
+
695
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
696
+
697
+ options.apply_defaults timeout: @config.rpcs.begin_transaction.timeout,
698
+ metadata: call_metadata,
699
+ retry_policy: @config.rpcs.begin_transaction.retry_policy
700
+
701
+ options.apply_defaults timeout: @config.timeout,
702
+ metadata: @config.metadata,
703
+ retry_policy: @config.retry_policy
704
+
705
+ @firestore_stub.begin_transaction request, options do |result, operation|
706
+ yield result, operation if block_given?
707
+ return result
708
+ end
709
+ rescue ::Gapic::Rest::Error => e
710
+ raise ::Google::Cloud::Error.from_error(e)
711
+ end
712
+
713
+ ##
714
+ # Commits a transaction, while optionally updating documents.
715
+ #
716
+ # @overload commit(request, options = nil)
717
+ # Pass arguments to `commit` via a request object, either of type
718
+ # {::Google::Cloud::Firestore::V1::CommitRequest} or an equivalent Hash.
719
+ #
720
+ # @param request [::Google::Cloud::Firestore::V1::CommitRequest, ::Hash]
721
+ # A request object representing the call parameters. Required. To specify no
722
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
723
+ # @param options [::Gapic::CallOptions, ::Hash]
724
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
725
+ #
726
+ # @overload commit(database: nil, writes: nil, transaction: nil)
727
+ # Pass arguments to `commit` via keyword arguments. Note that at
728
+ # least one keyword argument is required. To specify no parameters, or to keep all
729
+ # the default parameter values, pass an empty Hash as a request object (see above).
730
+ #
731
+ # @param database [::String]
732
+ # Required. The database name. In the format:
733
+ # `projects/{project_id}/databases/{database_id}`.
734
+ # @param writes [::Array<::Google::Cloud::Firestore::V1::Write, ::Hash>]
735
+ # The writes to apply.
736
+ #
737
+ # Always executed atomically and in order.
738
+ # @param transaction [::String]
739
+ # If set, applies all writes in this transaction, and commits it.
740
+ # @yield [result, operation] Access the result along with the TransportOperation object
741
+ # @yieldparam result [::Google::Cloud::Firestore::V1::CommitResponse]
742
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
743
+ #
744
+ # @return [::Google::Cloud::Firestore::V1::CommitResponse]
745
+ #
746
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
747
+ def commit request, options = nil
748
+ raise ::ArgumentError, "request must be provided" if request.nil?
749
+
750
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::CommitRequest
751
+
752
+ # Converts hash and nil to an options object
753
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
754
+
755
+ # Customize the options with defaults
756
+ call_metadata = @config.rpcs.commit.metadata.to_h
757
+
758
+ # Set x-goog-api-client and x-goog-user-project headers
759
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
760
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
761
+ gapic_version: ::Google::Cloud::Firestore::V1::VERSION,
762
+ transports_version_send: [:rest]
763
+
764
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
765
+
766
+ options.apply_defaults timeout: @config.rpcs.commit.timeout,
767
+ metadata: call_metadata,
768
+ retry_policy: @config.rpcs.commit.retry_policy
769
+
770
+ options.apply_defaults timeout: @config.timeout,
771
+ metadata: @config.metadata,
772
+ retry_policy: @config.retry_policy
773
+
774
+ @firestore_stub.commit request, options do |result, operation|
775
+ yield result, operation if block_given?
776
+ return result
777
+ end
778
+ rescue ::Gapic::Rest::Error => e
779
+ raise ::Google::Cloud::Error.from_error(e)
780
+ end
781
+
782
+ ##
783
+ # Rolls back a transaction.
784
+ #
785
+ # @overload rollback(request, options = nil)
786
+ # Pass arguments to `rollback` via a request object, either of type
787
+ # {::Google::Cloud::Firestore::V1::RollbackRequest} or an equivalent Hash.
788
+ #
789
+ # @param request [::Google::Cloud::Firestore::V1::RollbackRequest, ::Hash]
790
+ # A request object representing the call parameters. Required. To specify no
791
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
792
+ # @param options [::Gapic::CallOptions, ::Hash]
793
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
794
+ #
795
+ # @overload rollback(database: nil, transaction: nil)
796
+ # Pass arguments to `rollback` via keyword arguments. Note that at
797
+ # least one keyword argument is required. To specify no parameters, or to keep all
798
+ # the default parameter values, pass an empty Hash as a request object (see above).
799
+ #
800
+ # @param database [::String]
801
+ # Required. The database name. In the format:
802
+ # `projects/{project_id}/databases/{database_id}`.
803
+ # @param transaction [::String]
804
+ # Required. The transaction to roll back.
805
+ # @yield [result, operation] Access the result along with the TransportOperation object
806
+ # @yieldparam result [::Google::Protobuf::Empty]
807
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
808
+ #
809
+ # @return [::Google::Protobuf::Empty]
810
+ #
811
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
812
+ def rollback request, options = nil
813
+ raise ::ArgumentError, "request must be provided" if request.nil?
814
+
815
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::RollbackRequest
816
+
817
+ # Converts hash and nil to an options object
818
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
819
+
820
+ # Customize the options with defaults
821
+ call_metadata = @config.rpcs.rollback.metadata.to_h
822
+
823
+ # Set x-goog-api-client and x-goog-user-project headers
824
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
825
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
826
+ gapic_version: ::Google::Cloud::Firestore::V1::VERSION,
827
+ transports_version_send: [:rest]
828
+
829
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
830
+
831
+ options.apply_defaults timeout: @config.rpcs.rollback.timeout,
832
+ metadata: call_metadata,
833
+ retry_policy: @config.rpcs.rollback.retry_policy
834
+
835
+ options.apply_defaults timeout: @config.timeout,
836
+ metadata: @config.metadata,
837
+ retry_policy: @config.retry_policy
838
+
839
+ @firestore_stub.rollback request, options do |result, operation|
840
+ yield result, operation if block_given?
841
+ return result
842
+ end
843
+ rescue ::Gapic::Rest::Error => e
844
+ raise ::Google::Cloud::Error.from_error(e)
845
+ end
846
+
847
+ ##
848
+ # Runs a query.
849
+ #
850
+ # @overload run_query(request, options = nil)
851
+ # Pass arguments to `run_query` via a request object, either of type
852
+ # {::Google::Cloud::Firestore::V1::RunQueryRequest} or an equivalent Hash.
853
+ #
854
+ # @param request [::Google::Cloud::Firestore::V1::RunQueryRequest, ::Hash]
855
+ # A request object representing the call parameters. Required. To specify no
856
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
857
+ # @param options [::Gapic::CallOptions, ::Hash]
858
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
859
+ #
860
+ # @overload run_query(parent: nil, structured_query: nil, transaction: nil, new_transaction: nil, read_time: nil)
861
+ # Pass arguments to `run_query` via keyword arguments. Note that at
862
+ # least one keyword argument is required. To specify no parameters, or to keep all
863
+ # the default parameter values, pass an empty Hash as a request object (see above).
864
+ #
865
+ # @param parent [::String]
866
+ # Required. The parent resource name. In the format:
867
+ # `projects/{project_id}/databases/{database_id}/documents` or
868
+ # `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
869
+ # For example:
870
+ # `projects/my-project/databases/my-database/documents` or
871
+ # `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
872
+ # @param structured_query [::Google::Cloud::Firestore::V1::StructuredQuery, ::Hash]
873
+ # A structured query.
874
+ # @param transaction [::String]
875
+ # Run the query within an already active transaction.
876
+ #
877
+ # The value here is the opaque transaction ID to execute the query in.
878
+ # @param new_transaction [::Google::Cloud::Firestore::V1::TransactionOptions, ::Hash]
879
+ # Starts a new transaction and reads the documents.
880
+ # Defaults to a read-only transaction.
881
+ # The new transaction ID will be returned as the first response in the
882
+ # stream.
883
+ # @param read_time [::Google::Protobuf::Timestamp, ::Hash]
884
+ # Reads documents as they were at the given time.
885
+ # This may not be older than 270 seconds.
886
+ # @return [::Enumerable<::Google::Cloud::Firestore::V1::RunQueryResponse>]
887
+ #
888
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
889
+ def run_query request, options = nil
890
+ raise ::ArgumentError, "request must be provided" if request.nil?
891
+
892
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::RunQueryRequest
893
+
894
+ # Converts hash and nil to an options object
895
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
896
+
897
+ # Customize the options with defaults
898
+ call_metadata = @config.rpcs.run_query.metadata.to_h
899
+
900
+ # Set x-goog-api-client and x-goog-user-project headers
901
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
902
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
903
+ gapic_version: ::Google::Cloud::Firestore::V1::VERSION,
904
+ transports_version_send: [:rest]
905
+
906
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
907
+
908
+ options.apply_defaults timeout: @config.rpcs.run_query.timeout,
909
+ metadata: call_metadata,
910
+ retry_policy: @config.rpcs.run_query.retry_policy
911
+
912
+ options.apply_defaults timeout: @config.timeout,
913
+ metadata: @config.metadata,
914
+ retry_policy: @config.retry_policy
915
+
916
+ ::Gapic::Rest::ServerStream.new(
917
+ ::Google::Cloud::Firestore::V1::RunQueryResponse,
918
+ ::Gapic::Rest::ThreadedEnumerator.new do |in_q, out_q|
919
+ @firestore_stub.run_query request, options do |chunk|
920
+ in_q.deq
921
+ out_q.enq chunk
922
+ end
923
+ end
924
+ )
925
+ rescue ::Gapic::Rest::Error => e
926
+ raise ::Google::Cloud::Error.from_error(e)
927
+ end
928
+
929
+ ##
930
+ # Runs an aggregation query.
931
+ #
932
+ # Rather than producing {::Google::Cloud::Firestore::V1::Document Document} results like
933
+ # {::Google::Cloud::Firestore::V1::Firestore::Rest::Client#run_query Firestore.RunQuery}, this API
934
+ # allows running an aggregation to produce a series of
935
+ # {::Google::Cloud::Firestore::V1::AggregationResult AggregationResult} server-side.
936
+ #
937
+ # High-Level Example:
938
+ #
939
+ # ```
940
+ # -- Return the number of documents in table given a filter.
941
+ # SELECT COUNT(*) FROM ( SELECT * FROM k where a = true );
942
+ # ```
943
+ #
944
+ # @overload run_aggregation_query(request, options = nil)
945
+ # Pass arguments to `run_aggregation_query` via a request object, either of type
946
+ # {::Google::Cloud::Firestore::V1::RunAggregationQueryRequest} or an equivalent Hash.
947
+ #
948
+ # @param request [::Google::Cloud::Firestore::V1::RunAggregationQueryRequest, ::Hash]
949
+ # A request object representing the call parameters. Required. To specify no
950
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
951
+ # @param options [::Gapic::CallOptions, ::Hash]
952
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
953
+ #
954
+ # @overload run_aggregation_query(parent: nil, structured_aggregation_query: nil, transaction: nil, new_transaction: nil, read_time: nil)
955
+ # Pass arguments to `run_aggregation_query` via keyword arguments. Note that at
956
+ # least one keyword argument is required. To specify no parameters, or to keep all
957
+ # the default parameter values, pass an empty Hash as a request object (see above).
958
+ #
959
+ # @param parent [::String]
960
+ # Required. The parent resource name. In the format:
961
+ # `projects/{project_id}/databases/{database_id}/documents` or
962
+ # `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
963
+ # For example:
964
+ # `projects/my-project/databases/my-database/documents` or
965
+ # `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
966
+ # @param structured_aggregation_query [::Google::Cloud::Firestore::V1::StructuredAggregationQuery, ::Hash]
967
+ # An aggregation query.
968
+ # @param transaction [::String]
969
+ # Run the aggregation within an already active transaction.
970
+ #
971
+ # The value here is the opaque transaction ID to execute the query in.
972
+ # @param new_transaction [::Google::Cloud::Firestore::V1::TransactionOptions, ::Hash]
973
+ # Starts a new transaction as part of the query, defaulting to read-only.
974
+ #
975
+ # The new transaction ID will be returned as the first response in the
976
+ # stream.
977
+ # @param read_time [::Google::Protobuf::Timestamp, ::Hash]
978
+ # Executes the query at the given timestamp.
979
+ #
980
+ # Requires:
981
+ #
982
+ # * Cannot be more than 270 seconds in the past.
983
+ # @return [::Enumerable<::Google::Cloud::Firestore::V1::RunAggregationQueryResponse>]
984
+ #
985
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
986
+ def run_aggregation_query request, options = nil
987
+ raise ::ArgumentError, "request must be provided" if request.nil?
988
+
989
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::RunAggregationQueryRequest
990
+
991
+ # Converts hash and nil to an options object
992
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
993
+
994
+ # Customize the options with defaults
995
+ call_metadata = @config.rpcs.run_aggregation_query.metadata.to_h
996
+
997
+ # Set x-goog-api-client and x-goog-user-project headers
998
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
999
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1000
+ gapic_version: ::Google::Cloud::Firestore::V1::VERSION,
1001
+ transports_version_send: [:rest]
1002
+
1003
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1004
+
1005
+ options.apply_defaults timeout: @config.rpcs.run_aggregation_query.timeout,
1006
+ metadata: call_metadata,
1007
+ retry_policy: @config.rpcs.run_aggregation_query.retry_policy
1008
+
1009
+ options.apply_defaults timeout: @config.timeout,
1010
+ metadata: @config.metadata,
1011
+ retry_policy: @config.retry_policy
1012
+
1013
+ ::Gapic::Rest::ServerStream.new(
1014
+ ::Google::Cloud::Firestore::V1::RunAggregationQueryResponse,
1015
+ ::Gapic::Rest::ThreadedEnumerator.new do |in_q, out_q|
1016
+ @firestore_stub.run_aggregation_query request, options do |chunk|
1017
+ in_q.deq
1018
+ out_q.enq chunk
1019
+ end
1020
+ end
1021
+ )
1022
+ rescue ::Gapic::Rest::Error => e
1023
+ raise ::Google::Cloud::Error.from_error(e)
1024
+ end
1025
+
1026
+ ##
1027
+ # Partitions a query by returning partition cursors that can be used to run
1028
+ # the query in parallel. The returned partition cursors are split points that
1029
+ # can be used by RunQuery as starting/end points for the query results.
1030
+ #
1031
+ # @overload partition_query(request, options = nil)
1032
+ # Pass arguments to `partition_query` via a request object, either of type
1033
+ # {::Google::Cloud::Firestore::V1::PartitionQueryRequest} or an equivalent Hash.
1034
+ #
1035
+ # @param request [::Google::Cloud::Firestore::V1::PartitionQueryRequest, ::Hash]
1036
+ # A request object representing the call parameters. Required. To specify no
1037
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1038
+ # @param options [::Gapic::CallOptions, ::Hash]
1039
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1040
+ #
1041
+ # @overload partition_query(parent: nil, structured_query: nil, partition_count: nil, page_token: nil, page_size: nil, read_time: nil)
1042
+ # Pass arguments to `partition_query` via keyword arguments. Note that at
1043
+ # least one keyword argument is required. To specify no parameters, or to keep all
1044
+ # the default parameter values, pass an empty Hash as a request object (see above).
1045
+ #
1046
+ # @param parent [::String]
1047
+ # Required. The parent resource name. In the format:
1048
+ # `projects/{project_id}/databases/{database_id}/documents`.
1049
+ # Document resource names are not supported; only database resource names
1050
+ # can be specified.
1051
+ # @param structured_query [::Google::Cloud::Firestore::V1::StructuredQuery, ::Hash]
1052
+ # A structured query.
1053
+ # Query must specify collection with all descendants and be ordered by name
1054
+ # ascending. Other filters, order bys, limits, offsets, and start/end
1055
+ # cursors are not supported.
1056
+ # @param partition_count [::Integer]
1057
+ # The desired maximum number of partition points.
1058
+ # The partitions may be returned across multiple pages of results.
1059
+ # The number must be positive. The actual number of partitions
1060
+ # returned may be fewer.
1061
+ #
1062
+ # For example, this may be set to one fewer than the number of parallel
1063
+ # queries to be run, or in running a data pipeline job, one fewer than the
1064
+ # number of workers or compute instances available.
1065
+ # @param page_token [::String]
1066
+ # The `next_page_token` value returned from a previous call to
1067
+ # PartitionQuery that may be used to get an additional set of results.
1068
+ # There are no ordering guarantees between sets of results. Thus, using
1069
+ # multiple sets of results will require merging the different result sets.
1070
+ #
1071
+ # For example, two subsequent calls using a page_token may return:
1072
+ #
1073
+ # * cursor B, cursor M, cursor Q
1074
+ # * cursor A, cursor U, cursor W
1075
+ #
1076
+ # To obtain a complete result set ordered with respect to the results of the
1077
+ # query supplied to PartitionQuery, the results sets should be merged:
1078
+ # cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W
1079
+ # @param page_size [::Integer]
1080
+ # The maximum number of partitions to return in this call, subject to
1081
+ # `partition_count`.
1082
+ #
1083
+ # For example, if `partition_count` = 10 and `page_size` = 8, the first call
1084
+ # to PartitionQuery will return up to 8 partitions and a `next_page_token`
1085
+ # if more results exist. A second call to PartitionQuery will return up to
1086
+ # 2 partitions, to complete the total of 10 specified in `partition_count`.
1087
+ # @param read_time [::Google::Protobuf::Timestamp, ::Hash]
1088
+ # Reads documents as they were at the given time.
1089
+ # This may not be older than 270 seconds.
1090
+ # @yield [result, operation] Access the result along with the TransportOperation object
1091
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Firestore::V1::Cursor>]
1092
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1093
+ #
1094
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Firestore::V1::Cursor>]
1095
+ #
1096
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1097
+ def partition_query request, options = nil
1098
+ raise ::ArgumentError, "request must be provided" if request.nil?
1099
+
1100
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::PartitionQueryRequest
1101
+
1102
+ # Converts hash and nil to an options object
1103
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1104
+
1105
+ # Customize the options with defaults
1106
+ call_metadata = @config.rpcs.partition_query.metadata.to_h
1107
+
1108
+ # Set x-goog-api-client and x-goog-user-project headers
1109
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1110
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1111
+ gapic_version: ::Google::Cloud::Firestore::V1::VERSION,
1112
+ transports_version_send: [:rest]
1113
+
1114
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1115
+
1116
+ options.apply_defaults timeout: @config.rpcs.partition_query.timeout,
1117
+ metadata: call_metadata,
1118
+ retry_policy: @config.rpcs.partition_query.retry_policy
1119
+
1120
+ options.apply_defaults timeout: @config.timeout,
1121
+ metadata: @config.metadata,
1122
+ retry_policy: @config.retry_policy
1123
+
1124
+ @firestore_stub.partition_query request, options do |result, operation|
1125
+ result = ::Gapic::Rest::PagedEnumerable.new @firestore_stub, :partition_query, "partitions", request, result, options
1126
+ yield result, operation if block_given?
1127
+ return result
1128
+ end
1129
+ rescue ::Gapic::Rest::Error => e
1130
+ raise ::Google::Cloud::Error.from_error(e)
1131
+ end
1132
+
1133
+ ##
1134
+ # Lists all the collection IDs underneath a document.
1135
+ #
1136
+ # @overload list_collection_ids(request, options = nil)
1137
+ # Pass arguments to `list_collection_ids` via a request object, either of type
1138
+ # {::Google::Cloud::Firestore::V1::ListCollectionIdsRequest} or an equivalent Hash.
1139
+ #
1140
+ # @param request [::Google::Cloud::Firestore::V1::ListCollectionIdsRequest, ::Hash]
1141
+ # A request object representing the call parameters. Required. To specify no
1142
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1143
+ # @param options [::Gapic::CallOptions, ::Hash]
1144
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1145
+ #
1146
+ # @overload list_collection_ids(parent: nil, page_size: nil, page_token: nil, read_time: nil)
1147
+ # Pass arguments to `list_collection_ids` via keyword arguments. Note that at
1148
+ # least one keyword argument is required. To specify no parameters, or to keep all
1149
+ # the default parameter values, pass an empty Hash as a request object (see above).
1150
+ #
1151
+ # @param parent [::String]
1152
+ # Required. The parent document. In the format:
1153
+ # `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
1154
+ # For example:
1155
+ # `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
1156
+ # @param page_size [::Integer]
1157
+ # The maximum number of results to return.
1158
+ # @param page_token [::String]
1159
+ # A page token. Must be a value from
1160
+ # {::Google::Cloud::Firestore::V1::ListCollectionIdsResponse ListCollectionIdsResponse}.
1161
+ # @param read_time [::Google::Protobuf::Timestamp, ::Hash]
1162
+ # Reads documents as they were at the given time.
1163
+ # This may not be older than 270 seconds.
1164
+ # @yield [result, operation] Access the result along with the TransportOperation object
1165
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::String>]
1166
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1167
+ #
1168
+ # @return [::Gapic::Rest::PagedEnumerable<::String>]
1169
+ #
1170
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1171
+ def list_collection_ids request, options = nil
1172
+ raise ::ArgumentError, "request must be provided" if request.nil?
1173
+
1174
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::ListCollectionIdsRequest
1175
+
1176
+ # Converts hash and nil to an options object
1177
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1178
+
1179
+ # Customize the options with defaults
1180
+ call_metadata = @config.rpcs.list_collection_ids.metadata.to_h
1181
+
1182
+ # Set x-goog-api-client and x-goog-user-project headers
1183
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1184
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1185
+ gapic_version: ::Google::Cloud::Firestore::V1::VERSION,
1186
+ transports_version_send: [:rest]
1187
+
1188
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1189
+
1190
+ options.apply_defaults timeout: @config.rpcs.list_collection_ids.timeout,
1191
+ metadata: call_metadata,
1192
+ retry_policy: @config.rpcs.list_collection_ids.retry_policy
1193
+
1194
+ options.apply_defaults timeout: @config.timeout,
1195
+ metadata: @config.metadata,
1196
+ retry_policy: @config.retry_policy
1197
+
1198
+ @firestore_stub.list_collection_ids request, options do |result, operation|
1199
+ result = ::Gapic::Rest::PagedEnumerable.new @firestore_stub, :list_collection_ids, "collection_ids", request, result, options
1200
+ yield result, operation if block_given?
1201
+ return result
1202
+ end
1203
+ rescue ::Gapic::Rest::Error => e
1204
+ raise ::Google::Cloud::Error.from_error(e)
1205
+ end
1206
+
1207
+ ##
1208
+ # Applies a batch of write operations.
1209
+ #
1210
+ # The BatchWrite method does not apply the write operations atomically
1211
+ # and can apply them out of order. Method does not allow more than one write
1212
+ # per document. Each write succeeds or fails independently. See the
1213
+ # {::Google::Cloud::Firestore::V1::BatchWriteResponse BatchWriteResponse} for the
1214
+ # success status of each write.
1215
+ #
1216
+ # If you require an atomically applied set of writes, use
1217
+ # {::Google::Cloud::Firestore::V1::Firestore::Rest::Client#commit Commit} instead.
1218
+ #
1219
+ # @overload batch_write(request, options = nil)
1220
+ # Pass arguments to `batch_write` via a request object, either of type
1221
+ # {::Google::Cloud::Firestore::V1::BatchWriteRequest} or an equivalent Hash.
1222
+ #
1223
+ # @param request [::Google::Cloud::Firestore::V1::BatchWriteRequest, ::Hash]
1224
+ # A request object representing the call parameters. Required. To specify no
1225
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1226
+ # @param options [::Gapic::CallOptions, ::Hash]
1227
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1228
+ #
1229
+ # @overload batch_write(database: nil, writes: nil, labels: nil)
1230
+ # Pass arguments to `batch_write` via keyword arguments. Note that at
1231
+ # least one keyword argument is required. To specify no parameters, or to keep all
1232
+ # the default parameter values, pass an empty Hash as a request object (see above).
1233
+ #
1234
+ # @param database [::String]
1235
+ # Required. The database name. In the format:
1236
+ # `projects/{project_id}/databases/{database_id}`.
1237
+ # @param writes [::Array<::Google::Cloud::Firestore::V1::Write, ::Hash>]
1238
+ # The writes to apply.
1239
+ #
1240
+ # Method does not apply writes atomically and does not guarantee ordering.
1241
+ # Each write succeeds or fails independently. You cannot write to the same
1242
+ # document more than once per request.
1243
+ # @param labels [::Hash{::String => ::String}]
1244
+ # Labels associated with this batch write.
1245
+ # @yield [result, operation] Access the result along with the TransportOperation object
1246
+ # @yieldparam result [::Google::Cloud::Firestore::V1::BatchWriteResponse]
1247
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1248
+ #
1249
+ # @return [::Google::Cloud::Firestore::V1::BatchWriteResponse]
1250
+ #
1251
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1252
+ def batch_write request, options = nil
1253
+ raise ::ArgumentError, "request must be provided" if request.nil?
1254
+
1255
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::BatchWriteRequest
1256
+
1257
+ # Converts hash and nil to an options object
1258
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1259
+
1260
+ # Customize the options with defaults
1261
+ call_metadata = @config.rpcs.batch_write.metadata.to_h
1262
+
1263
+ # Set x-goog-api-client and x-goog-user-project headers
1264
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1265
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1266
+ gapic_version: ::Google::Cloud::Firestore::V1::VERSION,
1267
+ transports_version_send: [:rest]
1268
+
1269
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1270
+
1271
+ options.apply_defaults timeout: @config.rpcs.batch_write.timeout,
1272
+ metadata: call_metadata,
1273
+ retry_policy: @config.rpcs.batch_write.retry_policy
1274
+
1275
+ options.apply_defaults timeout: @config.timeout,
1276
+ metadata: @config.metadata,
1277
+ retry_policy: @config.retry_policy
1278
+
1279
+ @firestore_stub.batch_write request, options do |result, operation|
1280
+ yield result, operation if block_given?
1281
+ return result
1282
+ end
1283
+ rescue ::Gapic::Rest::Error => e
1284
+ raise ::Google::Cloud::Error.from_error(e)
1285
+ end
1286
+
1287
+ ##
1288
+ # Creates a new document.
1289
+ #
1290
+ # @overload create_document(request, options = nil)
1291
+ # Pass arguments to `create_document` via a request object, either of type
1292
+ # {::Google::Cloud::Firestore::V1::CreateDocumentRequest} or an equivalent Hash.
1293
+ #
1294
+ # @param request [::Google::Cloud::Firestore::V1::CreateDocumentRequest, ::Hash]
1295
+ # A request object representing the call parameters. Required. To specify no
1296
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1297
+ # @param options [::Gapic::CallOptions, ::Hash]
1298
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1299
+ #
1300
+ # @overload create_document(parent: nil, collection_id: nil, document_id: nil, document: nil, mask: nil)
1301
+ # Pass arguments to `create_document` via keyword arguments. Note that at
1302
+ # least one keyword argument is required. To specify no parameters, or to keep all
1303
+ # the default parameter values, pass an empty Hash as a request object (see above).
1304
+ #
1305
+ # @param parent [::String]
1306
+ # Required. The parent resource. For example:
1307
+ # `projects/{project_id}/databases/{database_id}/documents` or
1308
+ # `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}`
1309
+ # @param collection_id [::String]
1310
+ # Required. The collection ID, relative to `parent`, to list. For example:
1311
+ # `chatrooms`.
1312
+ # @param document_id [::String]
1313
+ # The client-assigned document ID to use for this document.
1314
+ #
1315
+ # Optional. If not specified, an ID will be assigned by the service.
1316
+ # @param document [::Google::Cloud::Firestore::V1::Document, ::Hash]
1317
+ # Required. The document to create. `name` must not be set.
1318
+ # @param mask [::Google::Cloud::Firestore::V1::DocumentMask, ::Hash]
1319
+ # The fields to return. If not set, returns all fields.
1320
+ #
1321
+ # If the document has a field that is not present in this mask, that field
1322
+ # will not be returned in the response.
1323
+ # @yield [result, operation] Access the result along with the TransportOperation object
1324
+ # @yieldparam result [::Google::Cloud::Firestore::V1::Document]
1325
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1326
+ #
1327
+ # @return [::Google::Cloud::Firestore::V1::Document]
1328
+ #
1329
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1330
+ def create_document request, options = nil
1331
+ raise ::ArgumentError, "request must be provided" if request.nil?
1332
+
1333
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::CreateDocumentRequest
1334
+
1335
+ # Converts hash and nil to an options object
1336
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1337
+
1338
+ # Customize the options with defaults
1339
+ call_metadata = @config.rpcs.create_document.metadata.to_h
1340
+
1341
+ # Set x-goog-api-client and x-goog-user-project headers
1342
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1343
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1344
+ gapic_version: ::Google::Cloud::Firestore::V1::VERSION,
1345
+ transports_version_send: [:rest]
1346
+
1347
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1348
+
1349
+ options.apply_defaults timeout: @config.rpcs.create_document.timeout,
1350
+ metadata: call_metadata,
1351
+ retry_policy: @config.rpcs.create_document.retry_policy
1352
+
1353
+ options.apply_defaults timeout: @config.timeout,
1354
+ metadata: @config.metadata,
1355
+ retry_policy: @config.retry_policy
1356
+
1357
+ @firestore_stub.create_document request, options do |result, operation|
1358
+ yield result, operation if block_given?
1359
+ return result
1360
+ end
1361
+ rescue ::Gapic::Rest::Error => e
1362
+ raise ::Google::Cloud::Error.from_error(e)
1363
+ end
1364
+
1365
+ ##
1366
+ # Configuration class for the Firestore REST API.
1367
+ #
1368
+ # This class represents the configuration for Firestore REST,
1369
+ # providing control over timeouts, retry behavior, logging, transport
1370
+ # parameters, and other low-level controls. Certain parameters can also be
1371
+ # applied individually to specific RPCs. See
1372
+ # {::Google::Cloud::Firestore::V1::Firestore::Rest::Client::Configuration::Rpcs}
1373
+ # for a list of RPCs that can be configured independently.
1374
+ #
1375
+ # Configuration can be applied globally to all clients, or to a single client
1376
+ # on construction.
1377
+ #
1378
+ # @example
1379
+ #
1380
+ # # Modify the global config, setting the timeout for
1381
+ # # get_document to 20 seconds,
1382
+ # # and all remaining timeouts to 10 seconds.
1383
+ # ::Google::Cloud::Firestore::V1::Firestore::Rest::Client.configure do |config|
1384
+ # config.timeout = 10.0
1385
+ # config.rpcs.get_document.timeout = 20.0
1386
+ # end
1387
+ #
1388
+ # # Apply the above configuration only to a new client.
1389
+ # client = ::Google::Cloud::Firestore::V1::Firestore::Rest::Client.new do |config|
1390
+ # config.timeout = 10.0
1391
+ # config.rpcs.get_document.timeout = 20.0
1392
+ # end
1393
+ #
1394
+ # @!attribute [rw] endpoint
1395
+ # The hostname or hostname:port of the service endpoint.
1396
+ # Defaults to `"firestore.googleapis.com"`.
1397
+ # @return [::String]
1398
+ # @!attribute [rw] credentials
1399
+ # Credentials to send with calls. You may provide any of the following types:
1400
+ # * (`String`) The path to a service account key file in JSON format
1401
+ # * (`Hash`) A service account key as a Hash
1402
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
1403
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
1404
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
1405
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
1406
+ # * (`nil`) indicating no credentials
1407
+ # @return [::Object]
1408
+ # @!attribute [rw] scope
1409
+ # The OAuth scopes
1410
+ # @return [::Array<::String>]
1411
+ # @!attribute [rw] lib_name
1412
+ # The library name as recorded in instrumentation and logging
1413
+ # @return [::String]
1414
+ # @!attribute [rw] lib_version
1415
+ # The library version as recorded in instrumentation and logging
1416
+ # @return [::String]
1417
+ # @!attribute [rw] timeout
1418
+ # The call timeout in seconds.
1419
+ # @return [::Numeric]
1420
+ # @!attribute [rw] metadata
1421
+ # Additional headers to be sent with the call.
1422
+ # @return [::Hash{::Symbol=>::String}]
1423
+ # @!attribute [rw] retry_policy
1424
+ # The retry policy. The value is a hash with the following keys:
1425
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1426
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1427
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1428
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1429
+ # trigger a retry.
1430
+ # @return [::Hash]
1431
+ # @!attribute [rw] quota_project
1432
+ # A separate project against which to charge quota.
1433
+ # @return [::String]
1434
+ #
1435
+ class Configuration
1436
+ extend ::Gapic::Config
1437
+
1438
+ config_attr :endpoint, "firestore.googleapis.com", ::String
1439
+ config_attr :credentials, nil do |value|
1440
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
1441
+ allowed.any? { |klass| klass === value }
1442
+ end
1443
+ config_attr :scope, nil, ::String, ::Array, nil
1444
+ config_attr :lib_name, nil, ::String, nil
1445
+ config_attr :lib_version, nil, ::String, nil
1446
+ config_attr :timeout, nil, ::Numeric, nil
1447
+ config_attr :metadata, nil, ::Hash, nil
1448
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
1449
+ config_attr :quota_project, nil, ::String, nil
1450
+
1451
+ # @private
1452
+ def initialize parent_config = nil
1453
+ @parent_config = parent_config unless parent_config.nil?
1454
+
1455
+ yield self if block_given?
1456
+ end
1457
+
1458
+ ##
1459
+ # Configurations for individual RPCs
1460
+ # @return [Rpcs]
1461
+ #
1462
+ def rpcs
1463
+ @rpcs ||= begin
1464
+ parent_rpcs = nil
1465
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
1466
+ Rpcs.new parent_rpcs
1467
+ end
1468
+ end
1469
+
1470
+ ##
1471
+ # Configuration RPC class for the Firestore API.
1472
+ #
1473
+ # Includes fields providing the configuration for each RPC in this service.
1474
+ # Each configuration object is of type `Gapic::Config::Method` and includes
1475
+ # the following configuration fields:
1476
+ #
1477
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
1478
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
1479
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
1480
+ # include the following keys:
1481
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1482
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1483
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1484
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1485
+ # trigger a retry.
1486
+ #
1487
+ class Rpcs
1488
+ ##
1489
+ # RPC-specific configuration for `get_document`
1490
+ # @return [::Gapic::Config::Method]
1491
+ #
1492
+ attr_reader :get_document
1493
+ ##
1494
+ # RPC-specific configuration for `list_documents`
1495
+ # @return [::Gapic::Config::Method]
1496
+ #
1497
+ attr_reader :list_documents
1498
+ ##
1499
+ # RPC-specific configuration for `update_document`
1500
+ # @return [::Gapic::Config::Method]
1501
+ #
1502
+ attr_reader :update_document
1503
+ ##
1504
+ # RPC-specific configuration for `delete_document`
1505
+ # @return [::Gapic::Config::Method]
1506
+ #
1507
+ attr_reader :delete_document
1508
+ ##
1509
+ # RPC-specific configuration for `batch_get_documents`
1510
+ # @return [::Gapic::Config::Method]
1511
+ #
1512
+ attr_reader :batch_get_documents
1513
+ ##
1514
+ # RPC-specific configuration for `begin_transaction`
1515
+ # @return [::Gapic::Config::Method]
1516
+ #
1517
+ attr_reader :begin_transaction
1518
+ ##
1519
+ # RPC-specific configuration for `commit`
1520
+ # @return [::Gapic::Config::Method]
1521
+ #
1522
+ attr_reader :commit
1523
+ ##
1524
+ # RPC-specific configuration for `rollback`
1525
+ # @return [::Gapic::Config::Method]
1526
+ #
1527
+ attr_reader :rollback
1528
+ ##
1529
+ # RPC-specific configuration for `run_query`
1530
+ # @return [::Gapic::Config::Method]
1531
+ #
1532
+ attr_reader :run_query
1533
+ ##
1534
+ # RPC-specific configuration for `run_aggregation_query`
1535
+ # @return [::Gapic::Config::Method]
1536
+ #
1537
+ attr_reader :run_aggregation_query
1538
+ ##
1539
+ # RPC-specific configuration for `partition_query`
1540
+ # @return [::Gapic::Config::Method]
1541
+ #
1542
+ attr_reader :partition_query
1543
+ ##
1544
+ # RPC-specific configuration for `list_collection_ids`
1545
+ # @return [::Gapic::Config::Method]
1546
+ #
1547
+ attr_reader :list_collection_ids
1548
+ ##
1549
+ # RPC-specific configuration for `batch_write`
1550
+ # @return [::Gapic::Config::Method]
1551
+ #
1552
+ attr_reader :batch_write
1553
+ ##
1554
+ # RPC-specific configuration for `create_document`
1555
+ # @return [::Gapic::Config::Method]
1556
+ #
1557
+ attr_reader :create_document
1558
+
1559
+ # @private
1560
+ def initialize parent_rpcs = nil
1561
+ get_document_config = parent_rpcs.get_document if parent_rpcs.respond_to? :get_document
1562
+ @get_document = ::Gapic::Config::Method.new get_document_config
1563
+ list_documents_config = parent_rpcs.list_documents if parent_rpcs.respond_to? :list_documents
1564
+ @list_documents = ::Gapic::Config::Method.new list_documents_config
1565
+ update_document_config = parent_rpcs.update_document if parent_rpcs.respond_to? :update_document
1566
+ @update_document = ::Gapic::Config::Method.new update_document_config
1567
+ delete_document_config = parent_rpcs.delete_document if parent_rpcs.respond_to? :delete_document
1568
+ @delete_document = ::Gapic::Config::Method.new delete_document_config
1569
+ batch_get_documents_config = parent_rpcs.batch_get_documents if parent_rpcs.respond_to? :batch_get_documents
1570
+ @batch_get_documents = ::Gapic::Config::Method.new batch_get_documents_config
1571
+ begin_transaction_config = parent_rpcs.begin_transaction if parent_rpcs.respond_to? :begin_transaction
1572
+ @begin_transaction = ::Gapic::Config::Method.new begin_transaction_config
1573
+ commit_config = parent_rpcs.commit if parent_rpcs.respond_to? :commit
1574
+ @commit = ::Gapic::Config::Method.new commit_config
1575
+ rollback_config = parent_rpcs.rollback if parent_rpcs.respond_to? :rollback
1576
+ @rollback = ::Gapic::Config::Method.new rollback_config
1577
+ run_query_config = parent_rpcs.run_query if parent_rpcs.respond_to? :run_query
1578
+ @run_query = ::Gapic::Config::Method.new run_query_config
1579
+ run_aggregation_query_config = parent_rpcs.run_aggregation_query if parent_rpcs.respond_to? :run_aggregation_query
1580
+ @run_aggregation_query = ::Gapic::Config::Method.new run_aggregation_query_config
1581
+ partition_query_config = parent_rpcs.partition_query if parent_rpcs.respond_to? :partition_query
1582
+ @partition_query = ::Gapic::Config::Method.new partition_query_config
1583
+ list_collection_ids_config = parent_rpcs.list_collection_ids if parent_rpcs.respond_to? :list_collection_ids
1584
+ @list_collection_ids = ::Gapic::Config::Method.new list_collection_ids_config
1585
+ batch_write_config = parent_rpcs.batch_write if parent_rpcs.respond_to? :batch_write
1586
+ @batch_write = ::Gapic::Config::Method.new batch_write_config
1587
+ create_document_config = parent_rpcs.create_document if parent_rpcs.respond_to? :create_document
1588
+ @create_document = ::Gapic::Config::Method.new create_document_config
1589
+
1590
+ yield self if block_given?
1591
+ end
1592
+ end
1593
+ end
1594
+ end
1595
+ end
1596
+ end
1597
+ end
1598
+ end
1599
+ end
1600
+ end