google-cloud-firestore 1.3.0 → 1.4.4
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -0
- data/TROUBLESHOOTING.md +2 -8
- data/lib/google/cloud/firestore/admin.rb +1 -1
- data/lib/google/cloud/firestore/admin/v1.rb +1 -1
- data/lib/google/cloud/firestore/admin/v1/firestore_admin_client.rb +378 -237
- data/lib/google/cloud/firestore/admin/v1/firestore_admin_client_config.json +22 -18
- data/lib/google/cloud/firestore/service.rb +16 -10
- data/lib/google/cloud/firestore/v1/firestore_client.rb +61 -120
- data/lib/google/cloud/firestore/v1/firestore_client_config.json +10 -6
- data/lib/google/cloud/firestore/v1beta1.rb +2 -0
- data/lib/google/cloud/firestore/v1beta1/firestore_client.rb +492 -549
- data/lib/google/cloud/firestore/v1beta1/firestore_client_config.json +28 -28
- data/lib/google/cloud/firestore/version.rb +1 -1
- metadata +4 -4
@@ -7,7 +7,11 @@
|
|
7
7
|
"INTERNAL",
|
8
8
|
"UNAVAILABLE"
|
9
9
|
],
|
10
|
-
"non_idempotent": []
|
10
|
+
"non_idempotent": [],
|
11
|
+
"idempotent2": [
|
12
|
+
"DEADLINE_EXCEEDED",
|
13
|
+
"UNAVAILABLE"
|
14
|
+
]
|
11
15
|
},
|
12
16
|
"retry_params": {
|
13
17
|
"default": {
|
@@ -32,12 +36,12 @@
|
|
32
36
|
"methods": {
|
33
37
|
"GetDocument": {
|
34
38
|
"timeout_millis": 60000,
|
35
|
-
"retry_codes_name": "
|
39
|
+
"retry_codes_name": "idempotent2",
|
36
40
|
"retry_params_name": "default"
|
37
41
|
},
|
38
42
|
"ListDocuments": {
|
39
43
|
"timeout_millis": 60000,
|
40
|
-
"retry_codes_name": "
|
44
|
+
"retry_codes_name": "idempotent2",
|
41
45
|
"retry_params_name": "default"
|
42
46
|
},
|
43
47
|
"CreateDocument": {
|
@@ -56,7 +60,7 @@
|
|
56
60
|
"retry_params_name": "default"
|
57
61
|
},
|
58
62
|
"BatchGetDocuments": {
|
59
|
-
"timeout_millis":
|
63
|
+
"timeout_millis": 60000,
|
60
64
|
"retry_codes_name": "idempotent",
|
61
65
|
"retry_params_name": "streaming"
|
62
66
|
},
|
@@ -81,12 +85,12 @@
|
|
81
85
|
"retry_params_name": "streaming"
|
82
86
|
},
|
83
87
|
"Write": {
|
84
|
-
"timeout_millis":
|
88
|
+
"timeout_millis": 60000,
|
85
89
|
"retry_codes_name": "non_idempotent",
|
86
90
|
"retry_params_name": "streaming"
|
87
91
|
},
|
88
92
|
"Listen": {
|
89
|
-
"timeout_millis":
|
93
|
+
"timeout_millis": 60000,
|
90
94
|
"retry_codes_name": "idempotent",
|
91
95
|
"retry_params_name": "streaming"
|
92
96
|
},
|
@@ -33,6 +33,8 @@ module Google
|
|
33
33
|
module Cloud
|
34
34
|
module Firestore
|
35
35
|
module V1beta1
|
36
|
+
# @deprecated Use Google::Cloud::Firestore::V1::FirestoreClient instead.
|
37
|
+
#
|
36
38
|
# The Cloud Firestore service.
|
37
39
|
#
|
38
40
|
# This service exposes several types of comparable timestamps:
|
@@ -68,14 +70,14 @@ module Google
|
|
68
70
|
DEFAULT_TIMEOUT = 30
|
69
71
|
|
70
72
|
PAGE_DESCRIPTORS = {
|
71
|
-
"
|
73
|
+
"list_collection_ids" => Google::Gax::PageDescriptor.new(
|
72
74
|
"page_token",
|
73
75
|
"next_page_token",
|
74
|
-
"
|
75
|
-
"
|
76
|
+
"collection_ids"),
|
77
|
+
"list_documents" => Google::Gax::PageDescriptor.new(
|
76
78
|
"page_token",
|
77
79
|
"next_page_token",
|
78
|
-
"
|
80
|
+
"documents")
|
79
81
|
}.freeze
|
80
82
|
|
81
83
|
private_constant :PAGE_DESCRIPTORS
|
@@ -88,80 +90,6 @@ module Google
|
|
88
90
|
].freeze
|
89
91
|
|
90
92
|
|
91
|
-
ANY_PATH_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
92
|
-
"projects/{project}/databases/{database}/documents/{document}/{any_path=**}"
|
93
|
-
)
|
94
|
-
|
95
|
-
private_constant :ANY_PATH_PATH_TEMPLATE
|
96
|
-
|
97
|
-
DATABASE_ROOT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
98
|
-
"projects/{project}/databases/{database}"
|
99
|
-
)
|
100
|
-
|
101
|
-
private_constant :DATABASE_ROOT_PATH_TEMPLATE
|
102
|
-
|
103
|
-
DOCUMENT_PATH_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
104
|
-
"projects/{project}/databases/{database}/documents/{document_path=**}"
|
105
|
-
)
|
106
|
-
|
107
|
-
private_constant :DOCUMENT_PATH_PATH_TEMPLATE
|
108
|
-
|
109
|
-
DOCUMENT_ROOT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
110
|
-
"projects/{project}/databases/{database}/documents"
|
111
|
-
)
|
112
|
-
|
113
|
-
private_constant :DOCUMENT_ROOT_PATH_TEMPLATE
|
114
|
-
|
115
|
-
# Returns a fully-qualified any_path resource name string.
|
116
|
-
# @param project [String]
|
117
|
-
# @param database [String]
|
118
|
-
# @param document [String]
|
119
|
-
# @param any_path [String]
|
120
|
-
# @return [String]
|
121
|
-
def self.any_path_path project, database, document, any_path
|
122
|
-
ANY_PATH_PATH_TEMPLATE.render(
|
123
|
-
:"project" => project,
|
124
|
-
:"database" => database,
|
125
|
-
:"document" => document,
|
126
|
-
:"any_path" => any_path
|
127
|
-
)
|
128
|
-
end
|
129
|
-
|
130
|
-
# Returns a fully-qualified database_root resource name string.
|
131
|
-
# @param project [String]
|
132
|
-
# @param database [String]
|
133
|
-
# @return [String]
|
134
|
-
def self.database_root_path project, database
|
135
|
-
DATABASE_ROOT_PATH_TEMPLATE.render(
|
136
|
-
:"project" => project,
|
137
|
-
:"database" => database
|
138
|
-
)
|
139
|
-
end
|
140
|
-
|
141
|
-
# Returns a fully-qualified document_path resource name string.
|
142
|
-
# @param project [String]
|
143
|
-
# @param database [String]
|
144
|
-
# @param document_path [String]
|
145
|
-
# @return [String]
|
146
|
-
def self.document_path_path project, database, document_path
|
147
|
-
DOCUMENT_PATH_PATH_TEMPLATE.render(
|
148
|
-
:"project" => project,
|
149
|
-
:"database" => database,
|
150
|
-
:"document_path" => document_path
|
151
|
-
)
|
152
|
-
end
|
153
|
-
|
154
|
-
# Returns a fully-qualified document_root resource name string.
|
155
|
-
# @param project [String]
|
156
|
-
# @param database [String]
|
157
|
-
# @return [String]
|
158
|
-
def self.document_root_path project, database
|
159
|
-
DOCUMENT_ROOT_PATH_TEMPLATE.render(
|
160
|
-
:"project" => project,
|
161
|
-
:"database" => database
|
162
|
-
)
|
163
|
-
end
|
164
|
-
|
165
93
|
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
166
94
|
# Provides the means for authenticating requests made by the client. This parameter can
|
167
95
|
# be many types.
|
@@ -239,6 +167,9 @@ module Google
|
|
239
167
|
google_api_client.freeze
|
240
168
|
|
241
169
|
headers = { :"x-goog-api-client" => google_api_client }
|
170
|
+
if credentials.respond_to?(:quota_project_id) && credentials.quota_project_id
|
171
|
+
headers[:"x-goog-user-project"] = credentials.quota_project_id
|
172
|
+
end
|
242
173
|
headers.merge!(metadata) unless metadata.nil?
|
243
174
|
client_config_file = Pathname.new(__dir__).join(
|
244
175
|
"firestore_client_config.json"
|
@@ -271,32 +202,6 @@ module Google
|
|
271
202
|
&Google::Firestore::V1beta1::Firestore::Stub.method(:new)
|
272
203
|
)
|
273
204
|
|
274
|
-
@get_document = Google::Gax.create_api_call(
|
275
|
-
@firestore_stub.method(:get_document),
|
276
|
-
defaults["get_document"],
|
277
|
-
exception_transformer: exception_transformer,
|
278
|
-
params_extractor: proc do |request|
|
279
|
-
{'name' => request.name}
|
280
|
-
end
|
281
|
-
)
|
282
|
-
@list_documents = Google::Gax.create_api_call(
|
283
|
-
@firestore_stub.method(:list_documents),
|
284
|
-
defaults["list_documents"],
|
285
|
-
exception_transformer: exception_transformer
|
286
|
-
)
|
287
|
-
@create_document = Google::Gax.create_api_call(
|
288
|
-
@firestore_stub.method(:create_document),
|
289
|
-
defaults["create_document"],
|
290
|
-
exception_transformer: exception_transformer
|
291
|
-
)
|
292
|
-
@update_document = Google::Gax.create_api_call(
|
293
|
-
@firestore_stub.method(:update_document),
|
294
|
-
defaults["update_document"],
|
295
|
-
exception_transformer: exception_transformer,
|
296
|
-
params_extractor: proc do |request|
|
297
|
-
{'document.name' => request.document.name}
|
298
|
-
end
|
299
|
-
)
|
300
205
|
@delete_document = Google::Gax.create_api_call(
|
301
206
|
@firestore_stub.method(:delete_document),
|
302
207
|
defaults["delete_document"],
|
@@ -321,14 +226,6 @@ module Google
|
|
321
226
|
{'database' => request.database}
|
322
227
|
end
|
323
228
|
)
|
324
|
-
@commit = Google::Gax.create_api_call(
|
325
|
-
@firestore_stub.method(:commit),
|
326
|
-
defaults["commit"],
|
327
|
-
exception_transformer: exception_transformer,
|
328
|
-
params_extractor: proc do |request|
|
329
|
-
{'database' => request.database}
|
330
|
-
end
|
331
|
-
)
|
332
229
|
@rollback = Google::Gax.create_api_call(
|
333
230
|
@firestore_stub.method(:rollback),
|
334
231
|
defaults["rollback"],
|
@@ -363,351 +260,248 @@ module Google
|
|
363
260
|
{'parent' => request.parent}
|
364
261
|
end
|
365
262
|
)
|
263
|
+
@get_document = Google::Gax.create_api_call(
|
264
|
+
@firestore_stub.method(:get_document),
|
265
|
+
defaults["get_document"],
|
266
|
+
exception_transformer: exception_transformer,
|
267
|
+
params_extractor: proc do |request|
|
268
|
+
{'name' => request.name}
|
269
|
+
end
|
270
|
+
)
|
271
|
+
@list_documents = Google::Gax.create_api_call(
|
272
|
+
@firestore_stub.method(:list_documents),
|
273
|
+
defaults["list_documents"],
|
274
|
+
exception_transformer: exception_transformer
|
275
|
+
)
|
276
|
+
@create_document = Google::Gax.create_api_call(
|
277
|
+
@firestore_stub.method(:create_document),
|
278
|
+
defaults["create_document"],
|
279
|
+
exception_transformer: exception_transformer
|
280
|
+
)
|
281
|
+
@update_document = Google::Gax.create_api_call(
|
282
|
+
@firestore_stub.method(:update_document),
|
283
|
+
defaults["update_document"],
|
284
|
+
exception_transformer: exception_transformer,
|
285
|
+
params_extractor: proc do |request|
|
286
|
+
{'document.name' => request.document.name}
|
287
|
+
end
|
288
|
+
)
|
289
|
+
@commit = Google::Gax.create_api_call(
|
290
|
+
@firestore_stub.method(:commit),
|
291
|
+
defaults["commit"],
|
292
|
+
exception_transformer: exception_transformer,
|
293
|
+
params_extractor: proc do |request|
|
294
|
+
{'database' => request.database}
|
295
|
+
end
|
296
|
+
)
|
366
297
|
end
|
367
298
|
|
368
299
|
# Service calls
|
369
300
|
|
370
|
-
#
|
301
|
+
# Deletes a document.
|
371
302
|
#
|
372
303
|
# @param name [String]
|
373
|
-
# Required. The resource name of the Document to
|
304
|
+
# Required. The resource name of the Document to delete. In the format:
|
374
305
|
# `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
|
375
|
-
# @param
|
376
|
-
#
|
377
|
-
#
|
378
|
-
#
|
379
|
-
# will not be returned in the response.
|
380
|
-
# A hash of the same form as `Google::Firestore::V1beta1::DocumentMask`
|
381
|
-
# can also be provided.
|
382
|
-
# @param transaction [String]
|
383
|
-
# Reads the document in a transaction.
|
384
|
-
# @param read_time [Google::Protobuf::Timestamp | Hash]
|
385
|
-
# Reads the version of the document at the given time.
|
386
|
-
# This may not be older than 60 seconds.
|
387
|
-
# A hash of the same form as `Google::Protobuf::Timestamp`
|
306
|
+
# @param current_document [Google::Firestore::V1beta1::Precondition | Hash]
|
307
|
+
# An optional precondition on the document.
|
308
|
+
# The request will fail if this is set and not met by the target document.
|
309
|
+
# A hash of the same form as `Google::Firestore::V1beta1::Precondition`
|
388
310
|
# can also be provided.
|
389
311
|
# @param options [Google::Gax::CallOptions]
|
390
312
|
# Overrides the default settings for this call, e.g, timeout,
|
391
313
|
# retries, etc.
|
392
314
|
# @yield [result, operation] Access the result along with the RPC operation
|
393
|
-
# @yieldparam result [
|
315
|
+
# @yieldparam result []
|
394
316
|
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
395
|
-
# @return [Google::Firestore::V1beta1::Document]
|
396
317
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
397
318
|
# @example
|
398
319
|
# require "google/cloud/firestore/v1beta1"
|
399
320
|
#
|
400
321
|
# firestore_client = Google::Cloud::Firestore::V1beta1.new
|
401
|
-
#
|
402
|
-
#
|
322
|
+
#
|
323
|
+
# # TODO: Initialize `name`:
|
324
|
+
# name = ''
|
325
|
+
# firestore_client.delete_document(name)
|
403
326
|
|
404
|
-
def
|
327
|
+
def delete_document \
|
405
328
|
name,
|
406
|
-
|
407
|
-
transaction: nil,
|
408
|
-
read_time: nil,
|
329
|
+
current_document: nil,
|
409
330
|
options: nil,
|
410
331
|
&block
|
411
332
|
req = {
|
412
333
|
name: name,
|
413
|
-
|
414
|
-
transaction: transaction,
|
415
|
-
read_time: read_time
|
334
|
+
current_document: current_document
|
416
335
|
}.delete_if { |_, v| v.nil? }
|
417
|
-
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::
|
418
|
-
@
|
336
|
+
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::DeleteDocumentRequest)
|
337
|
+
@delete_document.call(req, options, &block)
|
338
|
+
nil
|
419
339
|
end
|
420
340
|
|
421
|
-
#
|
341
|
+
# Gets multiple documents.
|
422
342
|
#
|
423
|
-
#
|
424
|
-
#
|
425
|
-
#
|
343
|
+
# Documents returned by this method are not guaranteed to be returned in the
|
344
|
+
# same order that they were requested.
|
345
|
+
#
|
346
|
+
# @param database [String]
|
347
|
+
# Required. The database name. In the format:
|
348
|
+
# `projects/{project_id}/databases/{database_id}`.
|
349
|
+
# @param documents [Array<String>]
|
350
|
+
# The names of the documents to retrieve. In the format:
|
426
351
|
# `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
|
427
|
-
#
|
428
|
-
# `
|
429
|
-
# `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
|
430
|
-
# @param collection_id [String]
|
431
|
-
# Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`
|
432
|
-
# or `messages`.
|
433
|
-
# @param page_size [Integer]
|
434
|
-
# The maximum number of resources contained in the underlying API
|
435
|
-
# response. If page streaming is performed per-resource, this
|
436
|
-
# parameter does not affect the return value. If page streaming is
|
437
|
-
# performed per-page, this determines the maximum number of
|
438
|
-
# resources in a page.
|
439
|
-
# @param order_by [String]
|
440
|
-
# The order to sort results by. For example: `priority desc, name`.
|
352
|
+
# The request will fail if any of the document is not a child resource of the
|
353
|
+
# given `database`. Duplicate names will be elided.
|
441
354
|
# @param mask [Google::Firestore::V1beta1::DocumentMask | Hash]
|
442
355
|
# The fields to return. If not set, returns all fields.
|
443
356
|
#
|
444
|
-
# If a document has a field that is not present in this mask, that field
|
445
|
-
#
|
357
|
+
# If a document has a field that is not present in this mask, that field will
|
358
|
+
# not be returned in the response.
|
446
359
|
# A hash of the same form as `Google::Firestore::V1beta1::DocumentMask`
|
447
360
|
# can also be provided.
|
448
361
|
# @param transaction [String]
|
449
362
|
# Reads documents in a transaction.
|
363
|
+
# @param new_transaction [Google::Firestore::V1beta1::TransactionOptions | Hash]
|
364
|
+
# Starts a new transaction and reads the documents.
|
365
|
+
# Defaults to a read-only transaction.
|
366
|
+
# The new transaction ID will be returned as the first response in the
|
367
|
+
# stream.
|
368
|
+
# A hash of the same form as `Google::Firestore::V1beta1::TransactionOptions`
|
369
|
+
# can also be provided.
|
450
370
|
# @param read_time [Google::Protobuf::Timestamp | Hash]
|
451
371
|
# Reads documents as they were at the given time.
|
452
372
|
# This may not be older than 60 seconds.
|
453
373
|
# A hash of the same form as `Google::Protobuf::Timestamp`
|
454
374
|
# can also be provided.
|
455
|
-
# @param show_missing [true, false]
|
456
|
-
# If the list should show missing documents. A missing document is a
|
457
|
-
# document that does not exist but has sub-documents. These documents will
|
458
|
-
# be returned with a key but will not have fields, {Google::Firestore::V1beta1::Document#create_time Document#create_time},
|
459
|
-
# or {Google::Firestore::V1beta1::Document#update_time Document#update_time} set.
|
460
|
-
#
|
461
|
-
# Requests with `show_missing` may not specify `where` or
|
462
|
-
# `order_by`.
|
463
375
|
# @param options [Google::Gax::CallOptions]
|
464
376
|
# Overrides the default settings for this call, e.g, timeout,
|
465
377
|
# retries, etc.
|
466
|
-
# @
|
467
|
-
#
|
468
|
-
#
|
469
|
-
# @return [Google::Gax::PagedEnumerable<Google::Firestore::V1beta1::Document>]
|
470
|
-
# An enumerable of Google::Firestore::V1beta1::Document instances.
|
471
|
-
# See Google::Gax::PagedEnumerable documentation for other
|
472
|
-
# operations such as per-page iteration or access to the response
|
473
|
-
# object.
|
378
|
+
# @return [Enumerable<Google::Firestore::V1beta1::BatchGetDocumentsResponse>]
|
379
|
+
# An enumerable of Google::Firestore::V1beta1::BatchGetDocumentsResponse instances.
|
380
|
+
#
|
474
381
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
475
382
|
# @example
|
476
383
|
# require "google/cloud/firestore/v1beta1"
|
477
384
|
#
|
478
385
|
# firestore_client = Google::Cloud::Firestore::V1beta1.new
|
479
|
-
# formatted_parent = Google::Cloud::Firestore::V1beta1::FirestoreClient.any_path_path("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]")
|
480
|
-
#
|
481
|
-
# # TODO: Initialize `collection_id`:
|
482
|
-
# collection_id = ''
|
483
386
|
#
|
484
|
-
# #
|
485
|
-
#
|
387
|
+
# # TODO: Initialize `database`:
|
388
|
+
# database = ''
|
389
|
+
# firestore_client.batch_get_documents(database).each do |element|
|
486
390
|
# # Process element.
|
487
391
|
# end
|
488
|
-
#
|
489
|
-
# # Or iterate over results one page at a time.
|
490
|
-
# firestore_client.list_documents(formatted_parent, collection_id).each_page do |page|
|
491
|
-
# # Process each page at a time.
|
492
|
-
# page.each do |element|
|
493
|
-
# # Process element.
|
494
|
-
# end
|
495
|
-
# end
|
496
392
|
|
497
|
-
def
|
498
|
-
|
499
|
-
|
500
|
-
page_size: nil,
|
501
|
-
order_by: nil,
|
393
|
+
def batch_get_documents \
|
394
|
+
database,
|
395
|
+
documents: nil,
|
502
396
|
mask: nil,
|
503
397
|
transaction: nil,
|
398
|
+
new_transaction: nil,
|
504
399
|
read_time: nil,
|
505
|
-
|
506
|
-
options: nil,
|
507
|
-
&block
|
400
|
+
options: nil
|
508
401
|
req = {
|
509
|
-
|
510
|
-
|
511
|
-
page_size: page_size,
|
512
|
-
order_by: order_by,
|
402
|
+
database: database,
|
403
|
+
documents: documents,
|
513
404
|
mask: mask,
|
514
405
|
transaction: transaction,
|
515
|
-
|
516
|
-
|
406
|
+
new_transaction: new_transaction,
|
407
|
+
read_time: read_time
|
517
408
|
}.delete_if { |_, v| v.nil? }
|
518
|
-
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::
|
519
|
-
@
|
409
|
+
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::BatchGetDocumentsRequest)
|
410
|
+
@batch_get_documents.call(req, options)
|
520
411
|
end
|
521
412
|
|
522
|
-
#
|
523
|
-
#
|
524
|
-
# @param parent [String]
|
525
|
-
# Required. The parent resource. For example:
|
526
|
-
# `projects/{project_id}/databases/{database_id}/documents` or
|
527
|
-
# `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}`
|
528
|
-
# @param collection_id [String]
|
529
|
-
# Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`.
|
530
|
-
# @param document_id [String]
|
531
|
-
# The client-assigned document ID to use for this document.
|
413
|
+
# Starts a new transaction.
|
532
414
|
#
|
533
|
-
#
|
534
|
-
#
|
535
|
-
#
|
536
|
-
#
|
537
|
-
#
|
538
|
-
#
|
539
|
-
#
|
540
|
-
#
|
541
|
-
# If the document has a field that is not present in this mask, that field
|
542
|
-
# will not be returned in the response.
|
543
|
-
# A hash of the same form as `Google::Firestore::V1beta1::DocumentMask`
|
415
|
+
# @param database [String]
|
416
|
+
# Required. The database name. In the format:
|
417
|
+
# `projects/{project_id}/databases/{database_id}`.
|
418
|
+
# @param options_ [Google::Firestore::V1beta1::TransactionOptions | Hash]
|
419
|
+
# The options for the transaction.
|
420
|
+
# Defaults to a read-write transaction.
|
421
|
+
# A hash of the same form as `Google::Firestore::V1beta1::TransactionOptions`
|
544
422
|
# can also be provided.
|
545
423
|
# @param options [Google::Gax::CallOptions]
|
546
424
|
# Overrides the default settings for this call, e.g, timeout,
|
547
425
|
# retries, etc.
|
548
426
|
# @yield [result, operation] Access the result along with the RPC operation
|
549
|
-
# @yieldparam result [Google::Firestore::V1beta1::
|
427
|
+
# @yieldparam result [Google::Firestore::V1beta1::BeginTransactionResponse]
|
550
428
|
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
551
|
-
# @return [Google::Firestore::V1beta1::
|
429
|
+
# @return [Google::Firestore::V1beta1::BeginTransactionResponse]
|
552
430
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
553
431
|
# @example
|
554
432
|
# require "google/cloud/firestore/v1beta1"
|
555
433
|
#
|
556
434
|
# firestore_client = Google::Cloud::Firestore::V1beta1.new
|
557
|
-
# formatted_parent = Google::Cloud::Firestore::V1beta1::FirestoreClient.any_path_path("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]")
|
558
|
-
#
|
559
|
-
# # TODO: Initialize `collection_id`:
|
560
|
-
# collection_id = ''
|
561
435
|
#
|
562
|
-
# # TODO: Initialize `
|
563
|
-
#
|
564
|
-
#
|
565
|
-
# # TODO: Initialize `document`:
|
566
|
-
# document = {}
|
567
|
-
# response = firestore_client.create_document(formatted_parent, collection_id, document_id, document)
|
436
|
+
# # TODO: Initialize `database`:
|
437
|
+
# database = ''
|
438
|
+
# response = firestore_client.begin_transaction(database)
|
568
439
|
|
569
|
-
def
|
570
|
-
|
571
|
-
|
572
|
-
document_id,
|
573
|
-
document,
|
574
|
-
mask: nil,
|
440
|
+
def begin_transaction \
|
441
|
+
database,
|
442
|
+
options_: nil,
|
575
443
|
options: nil,
|
576
444
|
&block
|
577
445
|
req = {
|
578
|
-
|
579
|
-
|
580
|
-
document_id: document_id,
|
581
|
-
document: document,
|
582
|
-
mask: mask
|
446
|
+
database: database,
|
447
|
+
options: options_
|
583
448
|
}.delete_if { |_, v| v.nil? }
|
584
|
-
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::
|
585
|
-
@
|
449
|
+
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::BeginTransactionRequest)
|
450
|
+
@begin_transaction.call(req, options, &block)
|
586
451
|
end
|
587
452
|
|
588
|
-
#
|
589
|
-
#
|
590
|
-
# @param document [Google::Firestore::V1beta1::Document | Hash]
|
591
|
-
# Required. The updated document.
|
592
|
-
# Creates the document if it does not already exist.
|
593
|
-
# A hash of the same form as `Google::Firestore::V1beta1::Document`
|
594
|
-
# can also be provided.
|
595
|
-
# @param update_mask [Google::Firestore::V1beta1::DocumentMask | Hash]
|
596
|
-
# The fields to update.
|
597
|
-
# None of the field paths in the mask may contain a reserved name.
|
598
|
-
#
|
599
|
-
# If the document exists on the server and has fields not referenced in the
|
600
|
-
# mask, they are left unchanged.
|
601
|
-
# Fields referenced in the mask, but not present in the input document, are
|
602
|
-
# deleted from the document on the server.
|
603
|
-
# A hash of the same form as `Google::Firestore::V1beta1::DocumentMask`
|
604
|
-
# can also be provided.
|
605
|
-
# @param mask [Google::Firestore::V1beta1::DocumentMask | Hash]
|
606
|
-
# The fields to return. If not set, returns all fields.
|
453
|
+
# Rolls back a transaction.
|
607
454
|
#
|
608
|
-
#
|
609
|
-
#
|
610
|
-
#
|
611
|
-
#
|
612
|
-
#
|
613
|
-
# An optional precondition on the document.
|
614
|
-
# The request will fail if this is set and not met by the target document.
|
615
|
-
# A hash of the same form as `Google::Firestore::V1beta1::Precondition`
|
616
|
-
# can also be provided.
|
455
|
+
# @param database [String]
|
456
|
+
# Required. The database name. In the format:
|
457
|
+
# `projects/{project_id}/databases/{database_id}`.
|
458
|
+
# @param transaction [String]
|
459
|
+
# Required. The transaction to roll back.
|
617
460
|
# @param options [Google::Gax::CallOptions]
|
618
461
|
# Overrides the default settings for this call, e.g, timeout,
|
619
462
|
# retries, etc.
|
620
463
|
# @yield [result, operation] Access the result along with the RPC operation
|
621
|
-
# @yieldparam result [
|
464
|
+
# @yieldparam result []
|
622
465
|
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
623
|
-
# @return [Google::Firestore::V1beta1::Document]
|
624
466
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
625
467
|
# @example
|
626
468
|
# require "google/cloud/firestore/v1beta1"
|
627
469
|
#
|
628
470
|
# firestore_client = Google::Cloud::Firestore::V1beta1.new
|
629
471
|
#
|
630
|
-
# # TODO: Initialize `
|
631
|
-
#
|
632
|
-
#
|
633
|
-
# # TODO: Initialize `update_mask`:
|
634
|
-
# update_mask = {}
|
635
|
-
# response = firestore_client.update_document(document, update_mask)
|
636
|
-
|
637
|
-
def update_document \
|
638
|
-
document,
|
639
|
-
update_mask,
|
640
|
-
mask: nil,
|
641
|
-
current_document: nil,
|
642
|
-
options: nil,
|
643
|
-
&block
|
644
|
-
req = {
|
645
|
-
document: document,
|
646
|
-
update_mask: update_mask,
|
647
|
-
mask: mask,
|
648
|
-
current_document: current_document
|
649
|
-
}.delete_if { |_, v| v.nil? }
|
650
|
-
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::UpdateDocumentRequest)
|
651
|
-
@update_document.call(req, options, &block)
|
652
|
-
end
|
653
|
-
|
654
|
-
# Deletes a document.
|
655
|
-
#
|
656
|
-
# @param name [String]
|
657
|
-
# Required. The resource name of the Document to delete. In the format:
|
658
|
-
# `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
|
659
|
-
# @param current_document [Google::Firestore::V1beta1::Precondition | Hash]
|
660
|
-
# An optional precondition on the document.
|
661
|
-
# The request will fail if this is set and not met by the target document.
|
662
|
-
# A hash of the same form as `Google::Firestore::V1beta1::Precondition`
|
663
|
-
# can also be provided.
|
664
|
-
# @param options [Google::Gax::CallOptions]
|
665
|
-
# Overrides the default settings for this call, e.g, timeout,
|
666
|
-
# retries, etc.
|
667
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
668
|
-
# @yieldparam result []
|
669
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
670
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
671
|
-
# @example
|
672
|
-
# require "google/cloud/firestore/v1beta1"
|
472
|
+
# # TODO: Initialize `database`:
|
473
|
+
# database = ''
|
673
474
|
#
|
674
|
-
#
|
675
|
-
#
|
676
|
-
# firestore_client.
|
475
|
+
# # TODO: Initialize `transaction`:
|
476
|
+
# transaction = ''
|
477
|
+
# firestore_client.rollback(database, transaction)
|
677
478
|
|
678
|
-
def
|
679
|
-
|
680
|
-
|
479
|
+
def rollback \
|
480
|
+
database,
|
481
|
+
transaction,
|
681
482
|
options: nil,
|
682
483
|
&block
|
683
484
|
req = {
|
684
|
-
|
685
|
-
|
485
|
+
database: database,
|
486
|
+
transaction: transaction
|
686
487
|
}.delete_if { |_, v| v.nil? }
|
687
|
-
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::
|
688
|
-
@
|
488
|
+
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::RollbackRequest)
|
489
|
+
@rollback.call(req, options, &block)
|
689
490
|
nil
|
690
491
|
end
|
691
492
|
|
692
|
-
#
|
693
|
-
#
|
694
|
-
# Documents returned by this method are not guaranteed to be returned in the
|
695
|
-
# same order that they were requested.
|
493
|
+
# Runs a query.
|
696
494
|
#
|
697
|
-
# @param
|
698
|
-
# Required. The
|
699
|
-
# `projects/{project_id}/databases/{database_id}
|
700
|
-
# @param documents [Array<String>]
|
701
|
-
# The names of the documents to retrieve. In the format:
|
495
|
+
# @param parent [String]
|
496
|
+
# Required. The parent resource name. In the format:
|
497
|
+
# `projects/{project_id}/databases/{database_id}/documents` or
|
702
498
|
# `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
|
703
|
-
#
|
704
|
-
#
|
705
|
-
#
|
706
|
-
#
|
707
|
-
#
|
708
|
-
#
|
709
|
-
# not be returned in the response.
|
710
|
-
# A hash of the same form as `Google::Firestore::V1beta1::DocumentMask`
|
499
|
+
# For example:
|
500
|
+
# `projects/my-project/databases/my-database/documents` or
|
501
|
+
# `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
|
502
|
+
# @param structured_query [Google::Firestore::V1beta1::StructuredQuery | Hash]
|
503
|
+
# A structured query.
|
504
|
+
# A hash of the same form as `Google::Firestore::V1beta1::StructuredQuery`
|
711
505
|
# can also be provided.
|
712
506
|
# @param transaction [String]
|
713
507
|
# Reads documents in a transaction.
|
@@ -726,165 +520,226 @@ module Google
|
|
726
520
|
# @param options [Google::Gax::CallOptions]
|
727
521
|
# Overrides the default settings for this call, e.g, timeout,
|
728
522
|
# retries, etc.
|
729
|
-
# @return [Enumerable<Google::Firestore::V1beta1::
|
730
|
-
# An enumerable of Google::Firestore::V1beta1::
|
523
|
+
# @return [Enumerable<Google::Firestore::V1beta1::RunQueryResponse>]
|
524
|
+
# An enumerable of Google::Firestore::V1beta1::RunQueryResponse instances.
|
731
525
|
#
|
732
526
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
733
527
|
# @example
|
734
528
|
# require "google/cloud/firestore/v1beta1"
|
735
529
|
#
|
736
530
|
# firestore_client = Google::Cloud::Firestore::V1beta1.new
|
737
|
-
# formatted_database = Google::Cloud::Firestore::V1beta1::FirestoreClient.database_root_path("[PROJECT]", "[DATABASE]")
|
738
531
|
#
|
739
|
-
# # TODO: Initialize `
|
740
|
-
#
|
741
|
-
# firestore_client.
|
532
|
+
# # TODO: Initialize `parent`:
|
533
|
+
# parent = ''
|
534
|
+
# firestore_client.run_query(parent).each do |element|
|
742
535
|
# # Process element.
|
743
536
|
# end
|
744
537
|
|
745
|
-
def
|
746
|
-
|
747
|
-
|
748
|
-
mask: nil,
|
538
|
+
def run_query \
|
539
|
+
parent,
|
540
|
+
structured_query: nil,
|
749
541
|
transaction: nil,
|
750
542
|
new_transaction: nil,
|
751
543
|
read_time: nil,
|
752
544
|
options: nil
|
753
545
|
req = {
|
754
|
-
|
755
|
-
|
756
|
-
mask: mask,
|
546
|
+
parent: parent,
|
547
|
+
structured_query: structured_query,
|
757
548
|
transaction: transaction,
|
758
549
|
new_transaction: new_transaction,
|
759
550
|
read_time: read_time
|
760
551
|
}.delete_if { |_, v| v.nil? }
|
761
|
-
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::
|
762
|
-
@
|
552
|
+
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::RunQueryRequest)
|
553
|
+
@run_query.call(req, options)
|
763
554
|
end
|
764
555
|
|
765
|
-
#
|
556
|
+
# Streams batches of document updates and deletes, in order.
|
766
557
|
#
|
767
|
-
# @param
|
768
|
-
#
|
769
|
-
# `projects/{project_id}/databases/{database_id}`.
|
770
|
-
# @param options_ [Google::Firestore::V1beta1::TransactionOptions | Hash]
|
771
|
-
# The options for the transaction.
|
772
|
-
# Defaults to a read-write transaction.
|
773
|
-
# A hash of the same form as `Google::Firestore::V1beta1::TransactionOptions`
|
774
|
-
# can also be provided.
|
558
|
+
# @param reqs [Enumerable<Google::Firestore::V1beta1::WriteRequest>]
|
559
|
+
# The input requests.
|
775
560
|
# @param options [Google::Gax::CallOptions]
|
776
561
|
# Overrides the default settings for this call, e.g, timeout,
|
777
562
|
# retries, etc.
|
778
|
-
# @
|
779
|
-
#
|
780
|
-
#
|
781
|
-
# @return [Google::Firestore::V1beta1::BeginTransactionResponse]
|
563
|
+
# @return [Enumerable<Google::Firestore::V1beta1::WriteResponse>]
|
564
|
+
# An enumerable of Google::Firestore::V1beta1::WriteResponse instances.
|
565
|
+
#
|
782
566
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
567
|
+
#
|
568
|
+
# @note
|
569
|
+
# EXPERIMENTAL:
|
570
|
+
# Streaming requests are still undergoing review.
|
571
|
+
# This method interface might change in the future.
|
572
|
+
#
|
783
573
|
# @example
|
784
574
|
# require "google/cloud/firestore/v1beta1"
|
785
575
|
#
|
786
576
|
# firestore_client = Google::Cloud::Firestore::V1beta1.new
|
787
|
-
#
|
788
|
-
#
|
577
|
+
#
|
578
|
+
# # TODO: Initialize `database`:
|
579
|
+
# database = ''
|
580
|
+
# request = { database: database }
|
581
|
+
# requests = [request]
|
582
|
+
# firestore_client.write(requests).each do |element|
|
583
|
+
# # Process element.
|
584
|
+
# end
|
789
585
|
|
790
|
-
def
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
req = {
|
796
|
-
database: database,
|
797
|
-
options: options_
|
798
|
-
}.delete_if { |_, v| v.nil? }
|
799
|
-
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::BeginTransactionRequest)
|
800
|
-
@begin_transaction.call(req, options, &block)
|
586
|
+
def write reqs, options: nil
|
587
|
+
request_protos = reqs.lazy.map do |req|
|
588
|
+
Google::Gax::to_proto(req, Google::Firestore::V1beta1::WriteRequest)
|
589
|
+
end
|
590
|
+
@write.call(request_protos, options)
|
801
591
|
end
|
802
592
|
|
803
|
-
#
|
804
|
-
#
|
805
|
-
# @param database [String]
|
806
|
-
# Required. The database name. In the format:
|
807
|
-
# `projects/{project_id}/databases/{database_id}`.
|
808
|
-
# @param writes [Array<Google::Firestore::V1beta1::Write | Hash>]
|
809
|
-
# The writes to apply.
|
593
|
+
# Listens to changes.
|
810
594
|
#
|
811
|
-
#
|
812
|
-
#
|
813
|
-
# can also be provided.
|
814
|
-
# @param transaction [String]
|
815
|
-
# If set, applies all writes in this transaction, and commits it.
|
595
|
+
# @param reqs [Enumerable<Google::Firestore::V1beta1::ListenRequest>]
|
596
|
+
# The input requests.
|
816
597
|
# @param options [Google::Gax::CallOptions]
|
817
598
|
# Overrides the default settings for this call, e.g, timeout,
|
818
599
|
# retries, etc.
|
819
|
-
# @
|
820
|
-
#
|
821
|
-
#
|
822
|
-
# @return [Google::Firestore::V1beta1::CommitResponse]
|
600
|
+
# @return [Enumerable<Google::Firestore::V1beta1::ListenResponse>]
|
601
|
+
# An enumerable of Google::Firestore::V1beta1::ListenResponse instances.
|
602
|
+
#
|
823
603
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
604
|
+
#
|
605
|
+
# @note
|
606
|
+
# EXPERIMENTAL:
|
607
|
+
# Streaming requests are still undergoing review.
|
608
|
+
# This method interface might change in the future.
|
609
|
+
#
|
824
610
|
# @example
|
825
611
|
# require "google/cloud/firestore/v1beta1"
|
826
612
|
#
|
827
613
|
# firestore_client = Google::Cloud::Firestore::V1beta1.new
|
828
|
-
# formatted_database = Google::Cloud::Firestore::V1beta1::FirestoreClient.database_root_path("[PROJECT]", "[DATABASE]")
|
829
614
|
#
|
830
|
-
# # TODO: Initialize `
|
831
|
-
#
|
832
|
-
#
|
615
|
+
# # TODO: Initialize `database`:
|
616
|
+
# database = ''
|
617
|
+
# request = { database: database }
|
618
|
+
# requests = [request]
|
619
|
+
# firestore_client.listen(requests).each do |element|
|
620
|
+
# # Process element.
|
621
|
+
# end
|
833
622
|
|
834
|
-
def
|
835
|
-
|
836
|
-
|
837
|
-
|
623
|
+
def listen reqs, options: nil
|
624
|
+
request_protos = reqs.lazy.map do |req|
|
625
|
+
Google::Gax::to_proto(req, Google::Firestore::V1beta1::ListenRequest)
|
626
|
+
end
|
627
|
+
@listen.call(request_protos, options)
|
628
|
+
end
|
629
|
+
|
630
|
+
# Lists all the collection IDs underneath a document.
|
631
|
+
#
|
632
|
+
# @param parent [String]
|
633
|
+
# Required. The parent document. In the format:
|
634
|
+
# `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
|
635
|
+
# For example:
|
636
|
+
# `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
|
637
|
+
# @param page_size [Integer]
|
638
|
+
# The maximum number of resources contained in the underlying API
|
639
|
+
# response. If page streaming is performed per-resource, this
|
640
|
+
# parameter does not affect the return value. If page streaming is
|
641
|
+
# performed per-page, this determines the maximum number of
|
642
|
+
# resources in a page.
|
643
|
+
# @param options [Google::Gax::CallOptions]
|
644
|
+
# Overrides the default settings for this call, e.g, timeout,
|
645
|
+
# retries, etc.
|
646
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
647
|
+
# @yieldparam result [Google::Gax::PagedEnumerable<String>]
|
648
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
649
|
+
# @return [Google::Gax::PagedEnumerable<String>]
|
650
|
+
# An enumerable of String instances.
|
651
|
+
# See Google::Gax::PagedEnumerable documentation for other
|
652
|
+
# operations such as per-page iteration or access to the response
|
653
|
+
# object.
|
654
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
655
|
+
# @example
|
656
|
+
# require "google/cloud/firestore/v1beta1"
|
657
|
+
#
|
658
|
+
# firestore_client = Google::Cloud::Firestore::V1beta1.new
|
659
|
+
#
|
660
|
+
# # TODO: Initialize `parent`:
|
661
|
+
# parent = ''
|
662
|
+
#
|
663
|
+
# # Iterate over all results.
|
664
|
+
# firestore_client.list_collection_ids(parent).each do |element|
|
665
|
+
# # Process element.
|
666
|
+
# end
|
667
|
+
#
|
668
|
+
# # Or iterate over results one page at a time.
|
669
|
+
# firestore_client.list_collection_ids(parent).each_page do |page|
|
670
|
+
# # Process each page at a time.
|
671
|
+
# page.each do |element|
|
672
|
+
# # Process element.
|
673
|
+
# end
|
674
|
+
# end
|
675
|
+
|
676
|
+
def list_collection_ids \
|
677
|
+
parent,
|
678
|
+
page_size: nil,
|
838
679
|
options: nil,
|
839
680
|
&block
|
840
681
|
req = {
|
841
|
-
|
842
|
-
|
843
|
-
transaction: transaction
|
682
|
+
parent: parent,
|
683
|
+
page_size: page_size
|
844
684
|
}.delete_if { |_, v| v.nil? }
|
845
|
-
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::
|
846
|
-
@
|
685
|
+
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::ListCollectionIdsRequest)
|
686
|
+
@list_collection_ids.call(req, options, &block)
|
847
687
|
end
|
848
688
|
|
849
|
-
#
|
689
|
+
# Gets a single document.
|
850
690
|
#
|
851
|
-
# @param
|
852
|
-
# Required. The
|
853
|
-
# `projects/{project_id}/databases/{database_id}`.
|
691
|
+
# @param name [String]
|
692
|
+
# Required. The resource name of the Document to get. In the format:
|
693
|
+
# `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
|
694
|
+
# @param mask [Google::Firestore::V1beta1::DocumentMask | Hash]
|
695
|
+
# The fields to return. If not set, returns all fields.
|
696
|
+
#
|
697
|
+
# If the document has a field that is not present in this mask, that field
|
698
|
+
# will not be returned in the response.
|
699
|
+
# A hash of the same form as `Google::Firestore::V1beta1::DocumentMask`
|
700
|
+
# can also be provided.
|
854
701
|
# @param transaction [String]
|
855
|
-
#
|
702
|
+
# Reads the document in a transaction.
|
703
|
+
# @param read_time [Google::Protobuf::Timestamp | Hash]
|
704
|
+
# Reads the version of the document at the given time.
|
705
|
+
# This may not be older than 60 seconds.
|
706
|
+
# A hash of the same form as `Google::Protobuf::Timestamp`
|
707
|
+
# can also be provided.
|
856
708
|
# @param options [Google::Gax::CallOptions]
|
857
709
|
# Overrides the default settings for this call, e.g, timeout,
|
858
710
|
# retries, etc.
|
859
711
|
# @yield [result, operation] Access the result along with the RPC operation
|
860
|
-
# @yieldparam result []
|
712
|
+
# @yieldparam result [Google::Firestore::V1beta1::Document]
|
861
713
|
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
714
|
+
# @return [Google::Firestore::V1beta1::Document]
|
862
715
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
863
716
|
# @example
|
864
717
|
# require "google/cloud/firestore/v1beta1"
|
865
718
|
#
|
866
719
|
# firestore_client = Google::Cloud::Firestore::V1beta1.new
|
867
|
-
# formatted_database = Google::Cloud::Firestore::V1beta1::FirestoreClient.database_root_path("[PROJECT]", "[DATABASE]")
|
868
720
|
#
|
869
|
-
# # TODO: Initialize `
|
870
|
-
#
|
871
|
-
# firestore_client.
|
721
|
+
# # TODO: Initialize `name`:
|
722
|
+
# name = ''
|
723
|
+
# response = firestore_client.get_document(name)
|
872
724
|
|
873
|
-
def
|
874
|
-
|
875
|
-
|
725
|
+
def get_document \
|
726
|
+
name,
|
727
|
+
mask: nil,
|
728
|
+
transaction: nil,
|
729
|
+
read_time: nil,
|
876
730
|
options: nil,
|
877
731
|
&block
|
878
732
|
req = {
|
879
|
-
|
880
|
-
|
733
|
+
name: name,
|
734
|
+
mask: mask,
|
735
|
+
transaction: transaction,
|
736
|
+
read_time: read_time
|
881
737
|
}.delete_if { |_, v| v.nil? }
|
882
|
-
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::
|
883
|
-
@
|
884
|
-
nil
|
738
|
+
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::GetDocumentRequest)
|
739
|
+
@get_document.call(req, options, &block)
|
885
740
|
end
|
886
741
|
|
887
|
-
#
|
742
|
+
# Lists documents.
|
888
743
|
#
|
889
744
|
# @param parent [String]
|
890
745
|
# Required. The parent resource name. In the format:
|
@@ -893,183 +748,271 @@ module Google
|
|
893
748
|
# For example:
|
894
749
|
# `projects/my-project/databases/my-database/documents` or
|
895
750
|
# `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
|
896
|
-
# @param
|
897
|
-
#
|
898
|
-
#
|
751
|
+
# @param collection_id [String]
|
752
|
+
# Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`
|
753
|
+
# or `messages`.
|
754
|
+
# @param page_size [Integer]
|
755
|
+
# The maximum number of resources contained in the underlying API
|
756
|
+
# response. If page streaming is performed per-resource, this
|
757
|
+
# parameter does not affect the return value. If page streaming is
|
758
|
+
# performed per-page, this determines the maximum number of
|
759
|
+
# resources in a page.
|
760
|
+
# @param order_by [String]
|
761
|
+
# The order to sort results by. For example: `priority desc, name`.
|
762
|
+
# @param mask [Google::Firestore::V1beta1::DocumentMask | Hash]
|
763
|
+
# The fields to return. If not set, returns all fields.
|
764
|
+
#
|
765
|
+
# If a document has a field that is not present in this mask, that field
|
766
|
+
# will not be returned in the response.
|
767
|
+
# A hash of the same form as `Google::Firestore::V1beta1::DocumentMask`
|
899
768
|
# can also be provided.
|
900
769
|
# @param transaction [String]
|
901
770
|
# Reads documents in a transaction.
|
902
|
-
# @param new_transaction [Google::Firestore::V1beta1::TransactionOptions | Hash]
|
903
|
-
# Starts a new transaction and reads the documents.
|
904
|
-
# Defaults to a read-only transaction.
|
905
|
-
# The new transaction ID will be returned as the first response in the
|
906
|
-
# stream.
|
907
|
-
# A hash of the same form as `Google::Firestore::V1beta1::TransactionOptions`
|
908
|
-
# can also be provided.
|
909
771
|
# @param read_time [Google::Protobuf::Timestamp | Hash]
|
910
772
|
# Reads documents as they were at the given time.
|
911
773
|
# This may not be older than 60 seconds.
|
912
774
|
# A hash of the same form as `Google::Protobuf::Timestamp`
|
913
775
|
# can also be provided.
|
776
|
+
# @param show_missing [true, false]
|
777
|
+
# If the list should show missing documents. A missing document is a
|
778
|
+
# document that does not exist but has sub-documents. These documents will
|
779
|
+
# be returned with a key but will not have fields, {Google::Firestore::V1beta1::Document#create_time Document#create_time},
|
780
|
+
# or {Google::Firestore::V1beta1::Document#update_time Document#update_time} set.
|
781
|
+
#
|
782
|
+
# Requests with `show_missing` may not specify `where` or
|
783
|
+
# `order_by`.
|
914
784
|
# @param options [Google::Gax::CallOptions]
|
915
785
|
# Overrides the default settings for this call, e.g, timeout,
|
916
786
|
# retries, etc.
|
917
|
-
# @
|
918
|
-
#
|
919
|
-
#
|
787
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
788
|
+
# @yieldparam result [Google::Gax::PagedEnumerable<Google::Firestore::V1beta1::Document>]
|
789
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
790
|
+
# @return [Google::Gax::PagedEnumerable<Google::Firestore::V1beta1::Document>]
|
791
|
+
# An enumerable of Google::Firestore::V1beta1::Document instances.
|
792
|
+
# See Google::Gax::PagedEnumerable documentation for other
|
793
|
+
# operations such as per-page iteration or access to the response
|
794
|
+
# object.
|
920
795
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
921
796
|
# @example
|
922
797
|
# require "google/cloud/firestore/v1beta1"
|
923
798
|
#
|
924
799
|
# firestore_client = Google::Cloud::Firestore::V1beta1.new
|
925
|
-
#
|
926
|
-
#
|
800
|
+
#
|
801
|
+
# # TODO: Initialize `parent`:
|
802
|
+
# parent = ''
|
803
|
+
#
|
804
|
+
# # TODO: Initialize `collection_id`:
|
805
|
+
# collection_id = ''
|
806
|
+
#
|
807
|
+
# # Iterate over all results.
|
808
|
+
# firestore_client.list_documents(parent, collection_id).each do |element|
|
927
809
|
# # Process element.
|
928
810
|
# end
|
811
|
+
#
|
812
|
+
# # Or iterate over results one page at a time.
|
813
|
+
# firestore_client.list_documents(parent, collection_id).each_page do |page|
|
814
|
+
# # Process each page at a time.
|
815
|
+
# page.each do |element|
|
816
|
+
# # Process element.
|
817
|
+
# end
|
818
|
+
# end
|
929
819
|
|
930
|
-
def
|
820
|
+
def list_documents \
|
931
821
|
parent,
|
932
|
-
|
822
|
+
collection_id,
|
823
|
+
page_size: nil,
|
824
|
+
order_by: nil,
|
825
|
+
mask: nil,
|
933
826
|
transaction: nil,
|
934
|
-
new_transaction: nil,
|
935
827
|
read_time: nil,
|
936
|
-
|
828
|
+
show_missing: nil,
|
829
|
+
options: nil,
|
830
|
+
&block
|
937
831
|
req = {
|
938
832
|
parent: parent,
|
939
|
-
|
833
|
+
collection_id: collection_id,
|
834
|
+
page_size: page_size,
|
835
|
+
order_by: order_by,
|
836
|
+
mask: mask,
|
940
837
|
transaction: transaction,
|
941
|
-
|
942
|
-
|
838
|
+
read_time: read_time,
|
839
|
+
show_missing: show_missing
|
943
840
|
}.delete_if { |_, v| v.nil? }
|
944
|
-
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::
|
945
|
-
@
|
841
|
+
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::ListDocumentsRequest)
|
842
|
+
@list_documents.call(req, options, &block)
|
946
843
|
end
|
947
844
|
|
948
|
-
#
|
845
|
+
# Creates a new document.
|
949
846
|
#
|
950
|
-
# @param
|
951
|
-
# The
|
847
|
+
# @param parent [String]
|
848
|
+
# Required. The parent resource. For example:
|
849
|
+
# `projects/{project_id}/databases/{database_id}/documents` or
|
850
|
+
# `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}`
|
851
|
+
# @param collection_id [String]
|
852
|
+
# Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`.
|
853
|
+
# @param document [Google::Firestore::V1beta1::Document | Hash]
|
854
|
+
# Required. The document to create. `name` must not be set.
|
855
|
+
# A hash of the same form as `Google::Firestore::V1beta1::Document`
|
856
|
+
# can also be provided.
|
857
|
+
# @param document_id [String]
|
858
|
+
# The client-assigned document ID to use for this document.
|
859
|
+
#
|
860
|
+
# Optional. If not specified, an ID will be assigned by the service.
|
861
|
+
# @param mask [Google::Firestore::V1beta1::DocumentMask | Hash]
|
862
|
+
# The fields to return. If not set, returns all fields.
|
863
|
+
#
|
864
|
+
# If the document has a field that is not present in this mask, that field
|
865
|
+
# will not be returned in the response.
|
866
|
+
# A hash of the same form as `Google::Firestore::V1beta1::DocumentMask`
|
867
|
+
# can also be provided.
|
952
868
|
# @param options [Google::Gax::CallOptions]
|
953
869
|
# Overrides the default settings for this call, e.g, timeout,
|
954
870
|
# retries, etc.
|
955
|
-
# @
|
956
|
-
#
|
957
|
-
#
|
871
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
872
|
+
# @yieldparam result [Google::Firestore::V1beta1::Document]
|
873
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
874
|
+
# @return [Google::Firestore::V1beta1::Document]
|
958
875
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
959
|
-
#
|
960
|
-
# @note
|
961
|
-
# EXPERIMENTAL:
|
962
|
-
# Streaming requests are still undergoing review.
|
963
|
-
# This method interface might change in the future.
|
964
|
-
#
|
965
876
|
# @example
|
966
877
|
# require "google/cloud/firestore/v1beta1"
|
967
878
|
#
|
968
879
|
# firestore_client = Google::Cloud::Firestore::V1beta1.new
|
969
|
-
#
|
970
|
-
#
|
971
|
-
#
|
972
|
-
#
|
973
|
-
#
|
974
|
-
#
|
880
|
+
#
|
881
|
+
# # TODO: Initialize `parent`:
|
882
|
+
# parent = ''
|
883
|
+
#
|
884
|
+
# # TODO: Initialize `collection_id`:
|
885
|
+
# collection_id = ''
|
886
|
+
#
|
887
|
+
# # TODO: Initialize `document`:
|
888
|
+
# document = {}
|
889
|
+
# response = firestore_client.create_document(parent, collection_id, document)
|
975
890
|
|
976
|
-
def
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
891
|
+
def create_document \
|
892
|
+
parent,
|
893
|
+
collection_id,
|
894
|
+
document,
|
895
|
+
document_id: nil,
|
896
|
+
mask: nil,
|
897
|
+
options: nil,
|
898
|
+
&block
|
899
|
+
req = {
|
900
|
+
parent: parent,
|
901
|
+
collection_id: collection_id,
|
902
|
+
document: document,
|
903
|
+
document_id: document_id,
|
904
|
+
mask: mask
|
905
|
+
}.delete_if { |_, v| v.nil? }
|
906
|
+
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::CreateDocumentRequest)
|
907
|
+
@create_document.call(req, options, &block)
|
981
908
|
end
|
982
909
|
|
983
|
-
#
|
910
|
+
# Updates or inserts a document.
|
984
911
|
#
|
985
|
-
# @param
|
986
|
-
# The
|
912
|
+
# @param document [Google::Firestore::V1beta1::Document | Hash]
|
913
|
+
# Required. The updated document.
|
914
|
+
# Creates the document if it does not already exist.
|
915
|
+
# A hash of the same form as `Google::Firestore::V1beta1::Document`
|
916
|
+
# can also be provided.
|
917
|
+
# @param update_mask [Google::Firestore::V1beta1::DocumentMask | Hash]
|
918
|
+
# The fields to update.
|
919
|
+
# None of the field paths in the mask may contain a reserved name.
|
920
|
+
#
|
921
|
+
# If the document exists on the server and has fields not referenced in the
|
922
|
+
# mask, they are left unchanged.
|
923
|
+
# Fields referenced in the mask, but not present in the input document, are
|
924
|
+
# deleted from the document on the server.
|
925
|
+
# A hash of the same form as `Google::Firestore::V1beta1::DocumentMask`
|
926
|
+
# can also be provided.
|
927
|
+
# @param mask [Google::Firestore::V1beta1::DocumentMask | Hash]
|
928
|
+
# The fields to return. If not set, returns all fields.
|
929
|
+
#
|
930
|
+
# If the document has a field that is not present in this mask, that field
|
931
|
+
# will not be returned in the response.
|
932
|
+
# A hash of the same form as `Google::Firestore::V1beta1::DocumentMask`
|
933
|
+
# can also be provided.
|
934
|
+
# @param current_document [Google::Firestore::V1beta1::Precondition | Hash]
|
935
|
+
# An optional precondition on the document.
|
936
|
+
# The request will fail if this is set and not met by the target document.
|
937
|
+
# A hash of the same form as `Google::Firestore::V1beta1::Precondition`
|
938
|
+
# can also be provided.
|
987
939
|
# @param options [Google::Gax::CallOptions]
|
988
940
|
# Overrides the default settings for this call, e.g, timeout,
|
989
941
|
# retries, etc.
|
990
|
-
# @
|
991
|
-
#
|
992
|
-
#
|
942
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
943
|
+
# @yieldparam result [Google::Firestore::V1beta1::Document]
|
944
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
945
|
+
# @return [Google::Firestore::V1beta1::Document]
|
993
946
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
994
|
-
#
|
995
|
-
# @note
|
996
|
-
# EXPERIMENTAL:
|
997
|
-
# Streaming requests are still undergoing review.
|
998
|
-
# This method interface might change in the future.
|
999
|
-
#
|
1000
947
|
# @example
|
1001
948
|
# require "google/cloud/firestore/v1beta1"
|
1002
949
|
#
|
1003
950
|
# firestore_client = Google::Cloud::Firestore::V1beta1.new
|
1004
|
-
#
|
1005
|
-
#
|
1006
|
-
#
|
1007
|
-
# firestore_client.
|
1008
|
-
# # Process element.
|
1009
|
-
# end
|
951
|
+
#
|
952
|
+
# # TODO: Initialize `document`:
|
953
|
+
# document = {}
|
954
|
+
# response = firestore_client.update_document(document)
|
1010
955
|
|
1011
|
-
def
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
956
|
+
def update_document \
|
957
|
+
document,
|
958
|
+
update_mask: nil,
|
959
|
+
mask: nil,
|
960
|
+
current_document: nil,
|
961
|
+
options: nil,
|
962
|
+
&block
|
963
|
+
req = {
|
964
|
+
document: document,
|
965
|
+
update_mask: update_mask,
|
966
|
+
mask: mask,
|
967
|
+
current_document: current_document
|
968
|
+
}.delete_if { |_, v| v.nil? }
|
969
|
+
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::UpdateDocumentRequest)
|
970
|
+
@update_document.call(req, options, &block)
|
1016
971
|
end
|
1017
972
|
|
1018
|
-
#
|
973
|
+
# Commits a transaction, while optionally updating documents.
|
1019
974
|
#
|
1020
|
-
# @param
|
1021
|
-
# Required. The
|
1022
|
-
# `projects/{project_id}/databases/{database_id}
|
1023
|
-
#
|
1024
|
-
#
|
1025
|
-
#
|
1026
|
-
#
|
1027
|
-
#
|
1028
|
-
#
|
1029
|
-
#
|
1030
|
-
#
|
975
|
+
# @param database [String]
|
976
|
+
# Required. The database name. In the format:
|
977
|
+
# `projects/{project_id}/databases/{database_id}`.
|
978
|
+
# @param writes [Array<Google::Firestore::V1beta1::Write | Hash>]
|
979
|
+
# The writes to apply.
|
980
|
+
#
|
981
|
+
# Always executed atomically and in order.
|
982
|
+
# A hash of the same form as `Google::Firestore::V1beta1::Write`
|
983
|
+
# can also be provided.
|
984
|
+
# @param transaction [String]
|
985
|
+
# If set, applies all writes in this transaction, and commits it.
|
1031
986
|
# @param options [Google::Gax::CallOptions]
|
1032
987
|
# Overrides the default settings for this call, e.g, timeout,
|
1033
988
|
# retries, etc.
|
1034
989
|
# @yield [result, operation] Access the result along with the RPC operation
|
1035
|
-
# @yieldparam result [Google::
|
990
|
+
# @yieldparam result [Google::Firestore::V1beta1::CommitResponse]
|
1036
991
|
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
1037
|
-
# @return [Google::
|
1038
|
-
# An enumerable of String instances.
|
1039
|
-
# See Google::Gax::PagedEnumerable documentation for other
|
1040
|
-
# operations such as per-page iteration or access to the response
|
1041
|
-
# object.
|
992
|
+
# @return [Google::Firestore::V1beta1::CommitResponse]
|
1042
993
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1043
994
|
# @example
|
1044
995
|
# require "google/cloud/firestore/v1beta1"
|
1045
996
|
#
|
1046
997
|
# firestore_client = Google::Cloud::Firestore::V1beta1.new
|
1047
|
-
# formatted_parent = Google::Cloud::Firestore::V1beta1::FirestoreClient.any_path_path("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]")
|
1048
|
-
#
|
1049
|
-
# # Iterate over all results.
|
1050
|
-
# firestore_client.list_collection_ids(formatted_parent).each do |element|
|
1051
|
-
# # Process element.
|
1052
|
-
# end
|
1053
998
|
#
|
1054
|
-
# #
|
1055
|
-
#
|
1056
|
-
#
|
1057
|
-
# page.each do |element|
|
1058
|
-
# # Process element.
|
1059
|
-
# end
|
1060
|
-
# end
|
999
|
+
# # TODO: Initialize `database`:
|
1000
|
+
# database = ''
|
1001
|
+
# response = firestore_client.commit(database)
|
1061
1002
|
|
1062
|
-
def
|
1063
|
-
|
1064
|
-
|
1003
|
+
def commit \
|
1004
|
+
database,
|
1005
|
+
writes: nil,
|
1006
|
+
transaction: nil,
|
1065
1007
|
options: nil,
|
1066
1008
|
&block
|
1067
1009
|
req = {
|
1068
|
-
|
1069
|
-
|
1010
|
+
database: database,
|
1011
|
+
writes: writes,
|
1012
|
+
transaction: transaction
|
1070
1013
|
}.delete_if { |_, v| v.nil? }
|
1071
|
-
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::
|
1072
|
-
@
|
1014
|
+
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::CommitRequest)
|
1015
|
+
@commit.call(req, options, &block)
|
1073
1016
|
end
|
1074
1017
|
end
|
1075
1018
|
end
|