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