google-cloud-firestore 0.22.0 → 0.23.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.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/README.md +8 -8
- data/lib/google-cloud-firestore.rb +1 -1
- data/lib/google/cloud/firestore.rb +46 -0
- data/lib/google/cloud/firestore/batch.rb +1 -1
- data/lib/google/cloud/firestore/client.rb +18 -13
- data/lib/google/cloud/firestore/convert.rb +78 -35
- data/lib/google/cloud/firestore/credentials.rb +2 -12
- data/lib/google/cloud/firestore/document_change.rb +124 -0
- data/lib/google/cloud/firestore/document_listener.rb +125 -0
- data/lib/google/cloud/firestore/document_reference.rb +35 -0
- data/lib/google/cloud/firestore/document_snapshot.rb +91 -9
- data/lib/google/cloud/firestore/field_path.rb +23 -13
- data/lib/google/cloud/firestore/query.rb +513 -69
- data/lib/google/cloud/firestore/query_listener.rb +118 -0
- data/lib/google/cloud/firestore/query_snapshot.rb +121 -0
- data/lib/google/cloud/firestore/service.rb +8 -0
- data/lib/google/cloud/firestore/transaction.rb +2 -2
- data/lib/google/cloud/firestore/v1beta1.rb +62 -37
- data/lib/google/cloud/firestore/v1beta1/credentials.rb +41 -0
- data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/common.rb +1 -1
- data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/document.rb +5 -4
- data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/firestore.rb +1 -12
- data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/query.rb +4 -1
- data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/write.rb +37 -8
- data/lib/google/cloud/firestore/v1beta1/doc/google/protobuf/any.rb +1 -1
- data/lib/google/cloud/firestore/v1beta1/doc/google/protobuf/empty.rb +28 -0
- data/lib/google/cloud/firestore/v1beta1/doc/google/protobuf/timestamp.rb +1 -1
- data/lib/google/cloud/firestore/v1beta1/doc/google/protobuf/wrappers.rb +1 -1
- data/lib/google/cloud/firestore/v1beta1/doc/google/rpc/status.rb +1 -1
- data/lib/google/cloud/firestore/v1beta1/firestore_client.rb +124 -56
- data/lib/google/cloud/firestore/v1beta1/firestore_client_config.json +2 -2
- data/lib/google/cloud/firestore/version.rb +1 -1
- data/lib/google/cloud/firestore/watch/enumerator_queue.rb +47 -0
- data/lib/google/cloud/firestore/watch/inventory.rb +280 -0
- data/lib/google/cloud/firestore/watch/listener.rb +298 -0
- data/lib/google/cloud/firestore/watch/order.rb +98 -0
- data/lib/google/firestore/v1beta1/firestore_services_pb.rb +2 -4
- data/lib/google/firestore/v1beta1/query_pb.rb +1 -0
- data/lib/google/firestore/v1beta1/write_pb.rb +2 -0
- metadata +40 -3
- data/lib/google/cloud/firestore/v1beta1/doc/overview.rb +0 -53
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2018 Google LLC
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -14,17 +14,6 @@
|
|
14
14
|
|
15
15
|
module Google
|
16
16
|
module Firestore
|
17
|
-
##
|
18
|
-
# # Google Cloud Firestore API Contents
|
19
|
-
#
|
20
|
-
# | Class | Description |
|
21
|
-
# | ----- | ----------- |
|
22
|
-
# | [FirestoreClient][] | |
|
23
|
-
# | [Data Types][] | Data types for Google::Cloud::Firestore::V1beta1 |
|
24
|
-
#
|
25
|
-
# [FirestoreClient]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-firestore/latest/google/firestore/v1beta1/v1beta1/firestoreclient
|
26
|
-
# [Data Types]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-firestore/latest/google/firestore/v1beta1/v1beta1/datatypes
|
27
|
-
#
|
28
17
|
module V1beta1
|
29
18
|
# The request for {Google::Firestore::V1beta1::Firestore::GetDocument Firestore::GetDocument}.
|
30
19
|
# @!attribute [rw] name
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2018 Google LLC
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -138,6 +138,9 @@ module Google
|
|
138
138
|
|
139
139
|
# Equal.
|
140
140
|
EQUAL = 5
|
141
|
+
|
142
|
+
# Contains. Requires that the field is an array.
|
143
|
+
ARRAY_CONTAINS = 7
|
141
144
|
end
|
142
145
|
end
|
143
146
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2018 Google LLC
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -34,9 +34,10 @@ module Google
|
|
34
34
|
# The fields to update in this write.
|
35
35
|
#
|
36
36
|
# This field can be set only when the operation is +update+.
|
37
|
-
#
|
38
|
-
#
|
39
|
-
# mask
|
37
|
+
# If the mask is not set for an +update+ and the document exists, any
|
38
|
+
# existing data will be overwritten.
|
39
|
+
# If the mask is set and the document on the server has fields not covered by
|
40
|
+
# the mask, they are left unchanged.
|
40
41
|
# Fields referenced in the mask, but not present in the input document, are
|
41
42
|
# deleted from the document on the server.
|
42
43
|
# The field paths in this mask must not contain a reserved field name.
|
@@ -55,6 +56,7 @@ module Google
|
|
55
56
|
# @return [Array<Google::Firestore::V1beta1::DocumentTransform::FieldTransform>]
|
56
57
|
# The list of transformations to apply to the fields of the document, in
|
57
58
|
# order.
|
59
|
+
# This must not be empty.
|
58
60
|
class DocumentTransform
|
59
61
|
# A transformation of a field of the document.
|
60
62
|
# @!attribute [rw] field_path
|
@@ -64,13 +66,40 @@ module Google
|
|
64
66
|
# @!attribute [rw] set_to_server_value
|
65
67
|
# @return [Google::Firestore::V1beta1::DocumentTransform::FieldTransform::ServerValue]
|
66
68
|
# Sets the field to the given server value.
|
69
|
+
# @!attribute [rw] append_missing_elements
|
70
|
+
# @return [Google::Firestore::V1beta1::ArrayValue]
|
71
|
+
# Append the given elements in order if they are not already present in
|
72
|
+
# the current field value.
|
73
|
+
# If the field is not an array, or if the field does not yet exist, it is
|
74
|
+
# first set to the empty array.
|
75
|
+
#
|
76
|
+
# Equivalent numbers of different types (e.g. 3L and 3.0) are
|
77
|
+
# considered equal when checking if a value is missing.
|
78
|
+
# NaN is equal to NaN, and Null is equal to Null.
|
79
|
+
# If the input contains multiple equivalent values, only the first will
|
80
|
+
# be considered.
|
81
|
+
#
|
82
|
+
# The corresponding transform_result will be the null value.
|
83
|
+
# @!attribute [rw] remove_all_from_array
|
84
|
+
# @return [Google::Firestore::V1beta1::ArrayValue]
|
85
|
+
# Remove all of the given elements from the array in the field.
|
86
|
+
# If the field is not an array, or if the field does not yet exist, it is
|
87
|
+
# set to the empty array.
|
88
|
+
#
|
89
|
+
# Equivalent numbers of the different types (e.g. 3L and 3.0) are
|
90
|
+
# considered equal when deciding whether an element should be removed.
|
91
|
+
# NaN is equal to NaN, and Null is equal to Null.
|
92
|
+
# This will remove all equivalent values if there are duplicates.
|
93
|
+
#
|
94
|
+
# The corresponding transform_result will be the null value.
|
67
95
|
class FieldTransform
|
68
96
|
# A value that is calculated by the server.
|
69
97
|
module ServerValue
|
70
98
|
# Unspecified. This value must not be used.
|
71
99
|
SERVER_VALUE_UNSPECIFIED = 0
|
72
100
|
|
73
|
-
# The time at which the server processed the request
|
101
|
+
# The time at which the server processed the request, with millisecond
|
102
|
+
# precision.
|
74
103
|
REQUEST_TIME = 1
|
75
104
|
end
|
76
105
|
end
|
@@ -92,7 +121,7 @@ module Google
|
|
92
121
|
|
93
122
|
# A {Google::Firestore::V1beta1::Document Document} has changed.
|
94
123
|
#
|
95
|
-
# May be the result of multiple {Google::Firestore::V1beta1::Write
|
124
|
+
# May be the result of multiple {Google::Firestore::V1beta1::Write writes}, including deletes, that
|
96
125
|
# ultimately resulted in a new value for the {Google::Firestore::V1beta1::Document Document}.
|
97
126
|
#
|
98
127
|
# Multiple {Google::Firestore::V1beta1::DocumentChange DocumentChange} messages may be returned for the same logical
|
@@ -112,7 +141,7 @@ module Google
|
|
112
141
|
|
113
142
|
# A {Google::Firestore::V1beta1::Document Document} has been deleted.
|
114
143
|
#
|
115
|
-
# May be the result of multiple {Google::Firestore::V1beta1::Write
|
144
|
+
# May be the result of multiple {Google::Firestore::V1beta1::Write writes}, including updates, the
|
116
145
|
# last of which deleted the {Google::Firestore::V1beta1::Document Document}.
|
117
146
|
#
|
118
147
|
# Multiple {Google::Firestore::V1beta1::DocumentDelete DocumentDelete} messages may be returned for the same logical
|
@@ -157,7 +186,7 @@ module Google
|
|
157
186
|
# The target ID to which this filter applies.
|
158
187
|
# @!attribute [rw] count
|
159
188
|
# @return [Integer]
|
160
|
-
# The total count of documents that match {Google::Firestore::V1beta1::ExistenceFilter#target_id
|
189
|
+
# The total count of documents that match {Google::Firestore::V1beta1::ExistenceFilter#target_id target_id}.
|
161
190
|
#
|
162
191
|
# If different from the count of documents in the client that match, the
|
163
192
|
# client must manually determine which documents no longer match the target.
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Copyright 2018 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Google
|
16
|
+
module Protobuf
|
17
|
+
# A generic empty message that you can re-use to avoid defining duplicated
|
18
|
+
# empty messages in your APIs. A typical example is to use it as the request
|
19
|
+
# or the response type of an API method. For instance:
|
20
|
+
#
|
21
|
+
# service Foo {
|
22
|
+
# rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
|
23
|
+
# }
|
24
|
+
#
|
25
|
+
# The JSON representation for +Empty+ is empty JSON object +{}+.
|
26
|
+
class Empty; end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2018 Google LLC
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -18,9 +18,6 @@
|
|
18
18
|
# and updates to that file get reflected here through a refresh process.
|
19
19
|
# For the short term, the refresh process will only be runnable by Google
|
20
20
|
# engineers.
|
21
|
-
#
|
22
|
-
# The only allowed edits are to method and file documentation. A 3-way
|
23
|
-
# merge preserves those additions if the generated source changes.
|
24
21
|
|
25
22
|
require "json"
|
26
23
|
require "pathname"
|
@@ -28,7 +25,7 @@ require "pathname"
|
|
28
25
|
require "google/gax"
|
29
26
|
|
30
27
|
require "google/firestore/v1beta1/firestore_pb"
|
31
|
-
require "google/cloud/firestore/credentials"
|
28
|
+
require "google/cloud/firestore/v1beta1/credentials"
|
32
29
|
|
33
30
|
module Google
|
34
31
|
module Cloud
|
@@ -62,6 +59,9 @@ module Google
|
|
62
59
|
# The default port of the service.
|
63
60
|
DEFAULT_SERVICE_PORT = 443
|
64
61
|
|
62
|
+
# The default set of gRPC interceptors.
|
63
|
+
GRPC_INTERCEPTORS = []
|
64
|
+
|
65
65
|
DEFAULT_TIMEOUT = 30
|
66
66
|
|
67
67
|
PAGE_DESCRIPTORS = {
|
@@ -84,6 +84,7 @@ module Google
|
|
84
84
|
"https://www.googleapis.com/auth/datastore"
|
85
85
|
].freeze
|
86
86
|
|
87
|
+
|
87
88
|
DATABASE_ROOT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
88
89
|
"projects/{project}/databases/{database}"
|
89
90
|
)
|
@@ -182,16 +183,18 @@ module Google
|
|
182
183
|
# or the specified config is missing data points.
|
183
184
|
# @param timeout [Numeric]
|
184
185
|
# The default timeout, in seconds, for calls made through this client.
|
186
|
+
# @param metadata [Hash]
|
187
|
+
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
188
|
+
# @param exception_transformer [Proc]
|
189
|
+
# An optional proc that intercepts any exceptions raised during an API call to inject
|
190
|
+
# custom error handling.
|
185
191
|
def initialize \
|
186
|
-
service_path: SERVICE_ADDRESS,
|
187
|
-
port: DEFAULT_SERVICE_PORT,
|
188
|
-
channel: nil,
|
189
|
-
chan_creds: nil,
|
190
|
-
updater_proc: nil,
|
191
192
|
credentials: nil,
|
192
193
|
scopes: ALL_SCOPES,
|
193
194
|
client_config: {},
|
194
195
|
timeout: DEFAULT_TIMEOUT,
|
196
|
+
metadata: nil,
|
197
|
+
exception_transformer: nil,
|
195
198
|
lib_name: nil,
|
196
199
|
lib_version: ""
|
197
200
|
# These require statements are intentionally placed here to initialize
|
@@ -200,21 +203,10 @@ module Google
|
|
200
203
|
require "google/gax/grpc"
|
201
204
|
require "google/firestore/v1beta1/firestore_services_pb"
|
202
205
|
|
203
|
-
|
204
|
-
warn "The `channel`, `chan_creds`, and `updater_proc` parameters will be removed " \
|
205
|
-
"on 2017/09/08"
|
206
|
-
credentials ||= channel
|
207
|
-
credentials ||= chan_creds
|
208
|
-
credentials ||= updater_proc
|
209
|
-
end
|
210
|
-
if service_path != SERVICE_ADDRESS || port != DEFAULT_SERVICE_PORT
|
211
|
-
warn "`service_path` and `port` parameters are deprecated and will be removed"
|
212
|
-
end
|
213
|
-
|
214
|
-
credentials ||= Google::Cloud::Firestore::Credentials.default
|
206
|
+
credentials ||= Google::Cloud::Firestore::V1beta1::Credentials.default
|
215
207
|
|
216
208
|
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
217
|
-
updater_proc = Google::Cloud::Firestore::Credentials.new(credentials).updater_proc
|
209
|
+
updater_proc = Google::Cloud::Firestore::V1beta1::Credentials.new(credentials).updater_proc
|
218
210
|
end
|
219
211
|
if credentials.is_a?(GRPC::Core::Channel)
|
220
212
|
channel = credentials
|
@@ -229,13 +221,16 @@ module Google
|
|
229
221
|
updater_proc = credentials.updater_proc
|
230
222
|
end
|
231
223
|
|
224
|
+
package_version = Gem.loaded_specs['google-cloud-firestore'].version.version
|
225
|
+
|
232
226
|
google_api_client = "gl-ruby/#{RUBY_VERSION}"
|
233
227
|
google_api_client << " #{lib_name}/#{lib_version}" if lib_name
|
234
|
-
google_api_client << " gapic
|
228
|
+
google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
|
235
229
|
google_api_client << " grpc/#{GRPC::VERSION}"
|
236
230
|
google_api_client.freeze
|
237
231
|
|
238
232
|
headers = { :"x-goog-api-client" => google_api_client }
|
233
|
+
headers.merge!(metadata) unless metadata.nil?
|
239
234
|
client_config_file = Pathname.new(__dir__).join(
|
240
235
|
"firestore_client_config.json"
|
241
236
|
)
|
@@ -248,9 +243,14 @@ module Google
|
|
248
243
|
timeout,
|
249
244
|
page_descriptors: PAGE_DESCRIPTORS,
|
250
245
|
errors: Google::Gax::Grpc::API_ERRORS,
|
251
|
-
|
246
|
+
metadata: headers
|
252
247
|
)
|
253
248
|
end
|
249
|
+
|
250
|
+
# Allow overriding the service path/port in subclasses.
|
251
|
+
service_path = self.class::SERVICE_ADDRESS
|
252
|
+
port = self.class::DEFAULT_SERVICE_PORT
|
253
|
+
interceptors = self.class::GRPC_INTERCEPTORS
|
254
254
|
@firestore_stub = Google::Gax::Grpc.create_stub(
|
255
255
|
service_path,
|
256
256
|
port,
|
@@ -258,60 +258,74 @@ module Google
|
|
258
258
|
channel: channel,
|
259
259
|
updater_proc: updater_proc,
|
260
260
|
scopes: scopes,
|
261
|
+
interceptors: interceptors,
|
261
262
|
&Google::Firestore::V1beta1::Firestore::Stub.method(:new)
|
262
263
|
)
|
263
264
|
|
264
265
|
@get_document = Google::Gax.create_api_call(
|
265
266
|
@firestore_stub.method(:get_document),
|
266
|
-
defaults["get_document"]
|
267
|
+
defaults["get_document"],
|
268
|
+
exception_transformer: exception_transformer
|
267
269
|
)
|
268
270
|
@list_documents = Google::Gax.create_api_call(
|
269
271
|
@firestore_stub.method(:list_documents),
|
270
|
-
defaults["list_documents"]
|
272
|
+
defaults["list_documents"],
|
273
|
+
exception_transformer: exception_transformer
|
271
274
|
)
|
272
275
|
@create_document = Google::Gax.create_api_call(
|
273
276
|
@firestore_stub.method(:create_document),
|
274
|
-
defaults["create_document"]
|
277
|
+
defaults["create_document"],
|
278
|
+
exception_transformer: exception_transformer
|
275
279
|
)
|
276
280
|
@update_document = Google::Gax.create_api_call(
|
277
281
|
@firestore_stub.method(:update_document),
|
278
|
-
defaults["update_document"]
|
282
|
+
defaults["update_document"],
|
283
|
+
exception_transformer: exception_transformer
|
279
284
|
)
|
280
285
|
@delete_document = Google::Gax.create_api_call(
|
281
286
|
@firestore_stub.method(:delete_document),
|
282
|
-
defaults["delete_document"]
|
287
|
+
defaults["delete_document"],
|
288
|
+
exception_transformer: exception_transformer
|
283
289
|
)
|
284
290
|
@batch_get_documents = Google::Gax.create_api_call(
|
285
291
|
@firestore_stub.method(:batch_get_documents),
|
286
|
-
defaults["batch_get_documents"]
|
292
|
+
defaults["batch_get_documents"],
|
293
|
+
exception_transformer: exception_transformer
|
287
294
|
)
|
288
295
|
@begin_transaction = Google::Gax.create_api_call(
|
289
296
|
@firestore_stub.method(:begin_transaction),
|
290
|
-
defaults["begin_transaction"]
|
297
|
+
defaults["begin_transaction"],
|
298
|
+
exception_transformer: exception_transformer
|
291
299
|
)
|
292
300
|
@commit = Google::Gax.create_api_call(
|
293
301
|
@firestore_stub.method(:commit),
|
294
|
-
defaults["commit"]
|
302
|
+
defaults["commit"],
|
303
|
+
exception_transformer: exception_transformer
|
295
304
|
)
|
296
305
|
@rollback = Google::Gax.create_api_call(
|
297
306
|
@firestore_stub.method(:rollback),
|
298
|
-
defaults["rollback"]
|
307
|
+
defaults["rollback"],
|
308
|
+
exception_transformer: exception_transformer
|
299
309
|
)
|
300
310
|
@run_query = Google::Gax.create_api_call(
|
301
311
|
@firestore_stub.method(:run_query),
|
302
|
-
defaults["run_query"]
|
312
|
+
defaults["run_query"],
|
313
|
+
exception_transformer: exception_transformer
|
303
314
|
)
|
304
315
|
@write = Google::Gax.create_api_call(
|
305
316
|
@firestore_stub.method(:write),
|
306
|
-
defaults["write"]
|
317
|
+
defaults["write"],
|
318
|
+
exception_transformer: exception_transformer
|
307
319
|
)
|
308
320
|
@listen = Google::Gax.create_api_call(
|
309
321
|
@firestore_stub.method(:listen),
|
310
|
-
defaults["listen"]
|
322
|
+
defaults["listen"],
|
323
|
+
exception_transformer: exception_transformer
|
311
324
|
)
|
312
325
|
@list_collection_ids = Google::Gax.create_api_call(
|
313
326
|
@firestore_stub.method(:list_collection_ids),
|
314
|
-
defaults["list_collection_ids"]
|
327
|
+
defaults["list_collection_ids"],
|
328
|
+
exception_transformer: exception_transformer
|
315
329
|
)
|
316
330
|
end
|
317
331
|
|
@@ -339,6 +353,9 @@ module Google
|
|
339
353
|
# @param options [Google::Gax::CallOptions]
|
340
354
|
# Overrides the default settings for this call, e.g, timeout,
|
341
355
|
# retries, etc.
|
356
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
357
|
+
# @yieldparam result [Google::Firestore::V1beta1::Document]
|
358
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
342
359
|
# @return [Google::Firestore::V1beta1::Document]
|
343
360
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
344
361
|
# @example
|
@@ -353,7 +370,8 @@ module Google
|
|
353
370
|
mask: nil,
|
354
371
|
transaction: nil,
|
355
372
|
read_time: nil,
|
356
|
-
options: nil
|
373
|
+
options: nil,
|
374
|
+
&block
|
357
375
|
req = {
|
358
376
|
name: name,
|
359
377
|
mask: mask,
|
@@ -361,7 +379,7 @@ module Google
|
|
361
379
|
read_time: read_time
|
362
380
|
}.delete_if { |_, v| v.nil? }
|
363
381
|
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::GetDocumentRequest)
|
364
|
-
@get_document.call(req, options)
|
382
|
+
@get_document.call(req, options, &block)
|
365
383
|
end
|
366
384
|
|
367
385
|
# Lists documents.
|
@@ -409,6 +427,9 @@ module Google
|
|
409
427
|
# @param options [Google::Gax::CallOptions]
|
410
428
|
# Overrides the default settings for this call, e.g, timeout,
|
411
429
|
# retries, etc.
|
430
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
431
|
+
# @yieldparam result [Google::Gax::PagedEnumerable<Google::Firestore::V1beta1::Document>]
|
432
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
412
433
|
# @return [Google::Gax::PagedEnumerable<Google::Firestore::V1beta1::Document>]
|
413
434
|
# An enumerable of Google::Firestore::V1beta1::Document instances.
|
414
435
|
# See Google::Gax::PagedEnumerable documentation for other
|
@@ -420,6 +441,8 @@ module Google
|
|
420
441
|
#
|
421
442
|
# firestore_client = Google::Cloud::Firestore::V1beta1.new
|
422
443
|
# formatted_parent = Google::Cloud::Firestore::V1beta1::FirestoreClient.any_path_path("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]")
|
444
|
+
#
|
445
|
+
# # TODO: Initialize +collection_id+:
|
423
446
|
# collection_id = ''
|
424
447
|
#
|
425
448
|
# # Iterate over all results.
|
@@ -444,7 +467,8 @@ module Google
|
|
444
467
|
transaction: nil,
|
445
468
|
read_time: nil,
|
446
469
|
show_missing: nil,
|
447
|
-
options: nil
|
470
|
+
options: nil,
|
471
|
+
&block
|
448
472
|
req = {
|
449
473
|
parent: parent,
|
450
474
|
collection_id: collection_id,
|
@@ -456,7 +480,7 @@ module Google
|
|
456
480
|
show_missing: show_missing
|
457
481
|
}.delete_if { |_, v| v.nil? }
|
458
482
|
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::ListDocumentsRequest)
|
459
|
-
@list_documents.call(req, options)
|
483
|
+
@list_documents.call(req, options, &block)
|
460
484
|
end
|
461
485
|
|
462
486
|
# Creates a new document.
|
@@ -485,6 +509,9 @@ module Google
|
|
485
509
|
# @param options [Google::Gax::CallOptions]
|
486
510
|
# Overrides the default settings for this call, e.g, timeout,
|
487
511
|
# retries, etc.
|
512
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
513
|
+
# @yieldparam result [Google::Firestore::V1beta1::Document]
|
514
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
488
515
|
# @return [Google::Firestore::V1beta1::Document]
|
489
516
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
490
517
|
# @example
|
@@ -492,8 +519,14 @@ module Google
|
|
492
519
|
#
|
493
520
|
# firestore_client = Google::Cloud::Firestore::V1beta1.new
|
494
521
|
# formatted_parent = Google::Cloud::Firestore::V1beta1::FirestoreClient.any_path_path("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]")
|
522
|
+
#
|
523
|
+
# # TODO: Initialize +collection_id+:
|
495
524
|
# collection_id = ''
|
525
|
+
#
|
526
|
+
# # TODO: Initialize +document_id+:
|
496
527
|
# document_id = ''
|
528
|
+
#
|
529
|
+
# # TODO: Initialize +document+:
|
497
530
|
# document = {}
|
498
531
|
# response = firestore_client.create_document(formatted_parent, collection_id, document_id, document)
|
499
532
|
|
@@ -503,7 +536,8 @@ module Google
|
|
503
536
|
document_id,
|
504
537
|
document,
|
505
538
|
mask: nil,
|
506
|
-
options: nil
|
539
|
+
options: nil,
|
540
|
+
&block
|
507
541
|
req = {
|
508
542
|
parent: parent,
|
509
543
|
collection_id: collection_id,
|
@@ -512,7 +546,7 @@ module Google
|
|
512
546
|
mask: mask
|
513
547
|
}.delete_if { |_, v| v.nil? }
|
514
548
|
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::CreateDocumentRequest)
|
515
|
-
@create_document.call(req, options)
|
549
|
+
@create_document.call(req, options, &block)
|
516
550
|
end
|
517
551
|
|
518
552
|
# Updates or inserts a document.
|
@@ -547,13 +581,20 @@ module Google
|
|
547
581
|
# @param options [Google::Gax::CallOptions]
|
548
582
|
# Overrides the default settings for this call, e.g, timeout,
|
549
583
|
# retries, etc.
|
584
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
585
|
+
# @yieldparam result [Google::Firestore::V1beta1::Document]
|
586
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
550
587
|
# @return [Google::Firestore::V1beta1::Document]
|
551
588
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
552
589
|
# @example
|
553
590
|
# require "google/cloud/firestore/v1beta1"
|
554
591
|
#
|
555
592
|
# firestore_client = Google::Cloud::Firestore::V1beta1.new
|
593
|
+
#
|
594
|
+
# # TODO: Initialize +document+:
|
556
595
|
# document = {}
|
596
|
+
#
|
597
|
+
# # TODO: Initialize +update_mask+:
|
557
598
|
# update_mask = {}
|
558
599
|
# response = firestore_client.update_document(document, update_mask)
|
559
600
|
|
@@ -562,7 +603,8 @@ module Google
|
|
562
603
|
update_mask,
|
563
604
|
mask: nil,
|
564
605
|
current_document: nil,
|
565
|
-
options: nil
|
606
|
+
options: nil,
|
607
|
+
&block
|
566
608
|
req = {
|
567
609
|
document: document,
|
568
610
|
update_mask: update_mask,
|
@@ -570,7 +612,7 @@ module Google
|
|
570
612
|
current_document: current_document
|
571
613
|
}.delete_if { |_, v| v.nil? }
|
572
614
|
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::UpdateDocumentRequest)
|
573
|
-
@update_document.call(req, options)
|
615
|
+
@update_document.call(req, options, &block)
|
574
616
|
end
|
575
617
|
|
576
618
|
# Deletes a document.
|
@@ -586,6 +628,9 @@ module Google
|
|
586
628
|
# @param options [Google::Gax::CallOptions]
|
587
629
|
# Overrides the default settings for this call, e.g, timeout,
|
588
630
|
# retries, etc.
|
631
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
632
|
+
# @yieldparam result []
|
633
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
589
634
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
590
635
|
# @example
|
591
636
|
# require "google/cloud/firestore/v1beta1"
|
@@ -597,13 +642,14 @@ module Google
|
|
597
642
|
def delete_document \
|
598
643
|
name,
|
599
644
|
current_document: nil,
|
600
|
-
options: nil
|
645
|
+
options: nil,
|
646
|
+
&block
|
601
647
|
req = {
|
602
648
|
name: name,
|
603
649
|
current_document: current_document
|
604
650
|
}.delete_if { |_, v| v.nil? }
|
605
651
|
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::DeleteDocumentRequest)
|
606
|
-
@delete_document.call(req, options)
|
652
|
+
@delete_document.call(req, options, &block)
|
607
653
|
nil
|
608
654
|
end
|
609
655
|
|
@@ -653,6 +699,8 @@ module Google
|
|
653
699
|
#
|
654
700
|
# firestore_client = Google::Cloud::Firestore::V1beta1.new
|
655
701
|
# formatted_database = Google::Cloud::Firestore::V1beta1::FirestoreClient.database_root_path("[PROJECT]", "[DATABASE]")
|
702
|
+
#
|
703
|
+
# # TODO: Initialize +documents+:
|
656
704
|
# documents = []
|
657
705
|
# firestore_client.batch_get_documents(formatted_database, documents).each do |element|
|
658
706
|
# # Process element.
|
@@ -691,6 +739,9 @@ module Google
|
|
691
739
|
# @param options [Google::Gax::CallOptions]
|
692
740
|
# Overrides the default settings for this call, e.g, timeout,
|
693
741
|
# retries, etc.
|
742
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
743
|
+
# @yieldparam result [Google::Firestore::V1beta1::BeginTransactionResponse]
|
744
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
694
745
|
# @return [Google::Firestore::V1beta1::BeginTransactionResponse]
|
695
746
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
696
747
|
# @example
|
@@ -703,13 +754,14 @@ module Google
|
|
703
754
|
def begin_transaction \
|
704
755
|
database,
|
705
756
|
options_: nil,
|
706
|
-
options: nil
|
757
|
+
options: nil,
|
758
|
+
&block
|
707
759
|
req = {
|
708
760
|
database: database,
|
709
761
|
options: options_
|
710
762
|
}.delete_if { |_, v| v.nil? }
|
711
763
|
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::BeginTransactionRequest)
|
712
|
-
@begin_transaction.call(req, options)
|
764
|
+
@begin_transaction.call(req, options, &block)
|
713
765
|
end
|
714
766
|
|
715
767
|
# Commits a transaction, while optionally updating documents.
|
@@ -728,6 +780,9 @@ module Google
|
|
728
780
|
# @param options [Google::Gax::CallOptions]
|
729
781
|
# Overrides the default settings for this call, e.g, timeout,
|
730
782
|
# retries, etc.
|
783
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
784
|
+
# @yieldparam result [Google::Firestore::V1beta1::CommitResponse]
|
785
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
731
786
|
# @return [Google::Firestore::V1beta1::CommitResponse]
|
732
787
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
733
788
|
# @example
|
@@ -735,6 +790,8 @@ module Google
|
|
735
790
|
#
|
736
791
|
# firestore_client = Google::Cloud::Firestore::V1beta1.new
|
737
792
|
# formatted_database = Google::Cloud::Firestore::V1beta1::FirestoreClient.database_root_path("[PROJECT]", "[DATABASE]")
|
793
|
+
#
|
794
|
+
# # TODO: Initialize +writes+:
|
738
795
|
# writes = []
|
739
796
|
# response = firestore_client.commit(formatted_database, writes)
|
740
797
|
|
@@ -742,14 +799,15 @@ module Google
|
|
742
799
|
database,
|
743
800
|
writes,
|
744
801
|
transaction: nil,
|
745
|
-
options: nil
|
802
|
+
options: nil,
|
803
|
+
&block
|
746
804
|
req = {
|
747
805
|
database: database,
|
748
806
|
writes: writes,
|
749
807
|
transaction: transaction
|
750
808
|
}.delete_if { |_, v| v.nil? }
|
751
809
|
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::CommitRequest)
|
752
|
-
@commit.call(req, options)
|
810
|
+
@commit.call(req, options, &block)
|
753
811
|
end
|
754
812
|
|
755
813
|
# Rolls back a transaction.
|
@@ -762,25 +820,31 @@ module Google
|
|
762
820
|
# @param options [Google::Gax::CallOptions]
|
763
821
|
# Overrides the default settings for this call, e.g, timeout,
|
764
822
|
# retries, etc.
|
823
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
824
|
+
# @yieldparam result []
|
825
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
765
826
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
766
827
|
# @example
|
767
828
|
# require "google/cloud/firestore/v1beta1"
|
768
829
|
#
|
769
830
|
# firestore_client = Google::Cloud::Firestore::V1beta1.new
|
770
831
|
# formatted_database = Google::Cloud::Firestore::V1beta1::FirestoreClient.database_root_path("[PROJECT]", "[DATABASE]")
|
832
|
+
#
|
833
|
+
# # TODO: Initialize +transaction+:
|
771
834
|
# transaction = ''
|
772
835
|
# firestore_client.rollback(formatted_database, transaction)
|
773
836
|
|
774
837
|
def rollback \
|
775
838
|
database,
|
776
839
|
transaction,
|
777
|
-
options: nil
|
840
|
+
options: nil,
|
841
|
+
&block
|
778
842
|
req = {
|
779
843
|
database: database,
|
780
844
|
transaction: transaction
|
781
845
|
}.delete_if { |_, v| v.nil? }
|
782
846
|
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::RollbackRequest)
|
783
|
-
@rollback.call(req, options)
|
847
|
+
@rollback.call(req, options, &block)
|
784
848
|
nil
|
785
849
|
end
|
786
850
|
|
@@ -931,6 +995,9 @@ module Google
|
|
931
995
|
# @param options [Google::Gax::CallOptions]
|
932
996
|
# Overrides the default settings for this call, e.g, timeout,
|
933
997
|
# retries, etc.
|
998
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
999
|
+
# @yieldparam result [Google::Gax::PagedEnumerable<String>]
|
1000
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
934
1001
|
# @return [Google::Gax::PagedEnumerable<String>]
|
935
1002
|
# An enumerable of String instances.
|
936
1003
|
# See Google::Gax::PagedEnumerable documentation for other
|
@@ -959,13 +1026,14 @@ module Google
|
|
959
1026
|
def list_collection_ids \
|
960
1027
|
parent,
|
961
1028
|
page_size: nil,
|
962
|
-
options: nil
|
1029
|
+
options: nil,
|
1030
|
+
&block
|
963
1031
|
req = {
|
964
1032
|
parent: parent,
|
965
1033
|
page_size: page_size
|
966
1034
|
}.delete_if { |_, v| v.nil? }
|
967
1035
|
req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::ListCollectionIdsRequest)
|
968
|
-
@list_collection_ids.call(req, options)
|
1036
|
+
@list_collection_ids.call(req, options, &block)
|
969
1037
|
end
|
970
1038
|
end
|
971
1039
|
end
|