google-cloud-firestore 1.3.0 → 1.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -0
- data/TROUBLESHOOTING.md +2 -8
- data/lib/google/cloud/firestore/admin.rb +1 -1
- data/lib/google/cloud/firestore/admin/v1.rb +1 -1
- data/lib/google/cloud/firestore/admin/v1/firestore_admin_client.rb +378 -237
- data/lib/google/cloud/firestore/admin/v1/firestore_admin_client_config.json +22 -18
- data/lib/google/cloud/firestore/service.rb +16 -10
- data/lib/google/cloud/firestore/v1/firestore_client.rb +61 -120
- data/lib/google/cloud/firestore/v1/firestore_client_config.json +10 -6
- data/lib/google/cloud/firestore/v1beta1.rb +2 -0
- data/lib/google/cloud/firestore/v1beta1/firestore_client.rb +492 -549
- data/lib/google/cloud/firestore/v1beta1/firestore_client_config.json +28 -28
- data/lib/google/cloud/firestore/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 767d0de57b4cb69eb636c2dd85e95da99bab28356514daeae0cb29e87aac8989
|
4
|
+
data.tar.gz: 9a2c8ebd59ef8694fcfe1cd78c027acca7442ae638c90b125dbde4f7adc4a8e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93d63f0d8d61ff6c32c2b94b0d38e8b1a1deadfdbe3bd104558ffc6fa55f265701dc262fd4f1200ea9d1802d26f5e5f79cd9859452d6128d3b3e49e36eae044c
|
7
|
+
data.tar.gz: d43a9f1f2e7b0aeb0dbfd56f10a41790036f29199d1dec6862f4e97e14fd057baf72ed66a1d414073e5a590cecfbdbb0182524f486e63e4951ffa8aa11d8dfd0
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,35 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 1.4.4 / 2020-05-28
|
4
|
+
|
5
|
+
#### Documentation
|
6
|
+
|
7
|
+
* Fix a few broken links
|
8
|
+
|
9
|
+
### 1.4.3 / 2020-05-21
|
10
|
+
|
11
|
+
#### Bug Fixes
|
12
|
+
|
13
|
+
* Adjusted some default timeout and retry settings
|
14
|
+
|
15
|
+
### 1.4.2 / 2020-05-14
|
16
|
+
|
17
|
+
#### Bug Fixes
|
18
|
+
|
19
|
+
* Fix Ruby 2.7 keyword argument warning
|
20
|
+
|
21
|
+
### 1.4.1 / 2020-04-14
|
22
|
+
|
23
|
+
#### Bug Fixes
|
24
|
+
|
25
|
+
* Update the low-level interface to match service changes
|
26
|
+
|
27
|
+
### 1.4.0 / 2020-03-11
|
28
|
+
|
29
|
+
#### Features
|
30
|
+
|
31
|
+
* Support separate project setting for quota/billing
|
32
|
+
|
3
33
|
### 1.3.0 / 2020-03-02
|
4
34
|
|
5
35
|
#### Features
|
data/TROUBLESHOOTING.md
CHANGED
@@ -24,14 +24,8 @@ improved, *please* create a new issue on GitHub so we can talk about it.
|
|
24
24
|
|
25
25
|
- [New issue][gh-ruby]
|
26
26
|
|
27
|
-
Or, you can ask questions on the [Google Cloud Platform Slack][slack-ruby]. You
|
28
|
-
can use the "ruby" channel for general Ruby questions, or use the
|
29
|
-
"google-cloud-ruby" channel if you have questions about this gem in particular.
|
30
|
-
|
31
27
|
[so-ruby]: http://stackoverflow.com/questions/tagged/google-cloud-platform+ruby+firestore
|
32
28
|
|
33
|
-
[gh-search-ruby]: https://github.com/
|
34
|
-
|
35
|
-
[gh-ruby]: https://github.com/googlecloudplatform/google-cloud-ruby/issues/new
|
29
|
+
[gh-search-ruby]: https://github.com/googleapis/google-cloud-ruby/issues?q=label%3A%22api%3A+firestore%22
|
36
30
|
|
37
|
-
[
|
31
|
+
[gh-ruby]: https://github.com/googleapis/google-cloud-ruby/issues/new
|
@@ -49,7 +49,7 @@ module Google
|
|
49
49
|
# - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
|
50
50
|
# to see the full list of Cloud APIs that we cover.
|
51
51
|
#
|
52
|
-
# [Product Documentation]: https://cloud.google.com/firestore
|
52
|
+
# [Product Documentation]: https://cloud.google.com/firestore/docs/reference/rpc
|
53
53
|
#
|
54
54
|
# ## Enabling Logging
|
55
55
|
#
|
@@ -51,7 +51,7 @@ module Google
|
|
51
51
|
# - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
|
52
52
|
# to see the full list of Cloud APIs that we cover.
|
53
53
|
#
|
54
|
-
# [Product Documentation]: https://cloud.google.com/firestore
|
54
|
+
# [Product Documentation]: https://cloud.google.com/firestore/docs/reference/rpc
|
55
55
|
#
|
56
56
|
# ## Enabling Logging
|
57
57
|
#
|
@@ -24,6 +24,8 @@ require "json"
|
|
24
24
|
require "pathname"
|
25
25
|
|
26
26
|
require "google/gax"
|
27
|
+
require "google/gax/operation"
|
28
|
+
require "google/longrunning/operations_client"
|
27
29
|
|
28
30
|
require "google/firestore/admin/v1/firestore_admin_pb"
|
29
31
|
require "google/cloud/firestore/admin/v1/credentials"
|
@@ -74,6 +76,16 @@ module Google
|
|
74
76
|
"https://www.googleapis.com/auth/datastore"
|
75
77
|
].freeze
|
76
78
|
|
79
|
+
class OperationsClient < Google::Longrunning::OperationsClient
|
80
|
+
self::SERVICE_ADDRESS = FirestoreAdminClient::SERVICE_ADDRESS
|
81
|
+
self::GRPC_INTERCEPTORS = FirestoreAdminClient::GRPC_INTERCEPTORS
|
82
|
+
end
|
83
|
+
|
84
|
+
COLLECTION_GROUP_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
85
|
+
"projects/{project}/databases/{database}/collectionGroups/{collection}"
|
86
|
+
)
|
87
|
+
|
88
|
+
private_constant :COLLECTION_GROUP_PATH_TEMPLATE
|
77
89
|
|
78
90
|
DATABASE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
79
91
|
"projects/{project}/databases/{database}"
|
@@ -82,22 +94,29 @@ module Google
|
|
82
94
|
private_constant :DATABASE_PATH_TEMPLATE
|
83
95
|
|
84
96
|
FIELD_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
85
|
-
"projects/{project}/databases/{database}/collectionGroups/{
|
97
|
+
"projects/{project}/databases/{database}/collectionGroups/{collection}/fields/{field}"
|
86
98
|
)
|
87
99
|
|
88
100
|
private_constant :FIELD_PATH_TEMPLATE
|
89
101
|
|
90
102
|
INDEX_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
91
|
-
"projects/{project}/databases/{database}/collectionGroups/{
|
103
|
+
"projects/{project}/databases/{database}/collectionGroups/{collection}/indexes/{index}"
|
92
104
|
)
|
93
105
|
|
94
106
|
private_constant :INDEX_PATH_TEMPLATE
|
95
107
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
108
|
+
# Returns a fully-qualified collection_group resource name string.
|
109
|
+
# @param project [String]
|
110
|
+
# @param database [String]
|
111
|
+
# @param collection [String]
|
112
|
+
# @return [String]
|
113
|
+
def self.collection_group_path project, database, collection
|
114
|
+
COLLECTION_GROUP_PATH_TEMPLATE.render(
|
115
|
+
:"project" => project,
|
116
|
+
:"database" => database,
|
117
|
+
:"collection" => collection
|
118
|
+
)
|
119
|
+
end
|
101
120
|
|
102
121
|
# Returns a fully-qualified database resource name string.
|
103
122
|
# @param project [String]
|
@@ -113,43 +132,30 @@ module Google
|
|
113
132
|
# Returns a fully-qualified field resource name string.
|
114
133
|
# @param project [String]
|
115
134
|
# @param database [String]
|
116
|
-
# @param
|
117
|
-
# @param
|
135
|
+
# @param collection [String]
|
136
|
+
# @param field [String]
|
118
137
|
# @return [String]
|
119
|
-
def self.field_path project, database,
|
138
|
+
def self.field_path project, database, collection, field
|
120
139
|
FIELD_PATH_TEMPLATE.render(
|
121
140
|
:"project" => project,
|
122
141
|
:"database" => database,
|
123
|
-
:"
|
124
|
-
:"
|
142
|
+
:"collection" => collection,
|
143
|
+
:"field" => field
|
125
144
|
)
|
126
145
|
end
|
127
146
|
|
128
147
|
# Returns a fully-qualified index resource name string.
|
129
148
|
# @param project [String]
|
130
149
|
# @param database [String]
|
131
|
-
# @param
|
132
|
-
# @param
|
150
|
+
# @param collection [String]
|
151
|
+
# @param index [String]
|
133
152
|
# @return [String]
|
134
|
-
def self.index_path project, database,
|
153
|
+
def self.index_path project, database, collection, index
|
135
154
|
INDEX_PATH_TEMPLATE.render(
|
136
155
|
:"project" => project,
|
137
156
|
:"database" => database,
|
138
|
-
:"
|
139
|
-
:"
|
140
|
-
)
|
141
|
-
end
|
142
|
-
|
143
|
-
# Returns a fully-qualified parent resource name string.
|
144
|
-
# @param project [String]
|
145
|
-
# @param database [String]
|
146
|
-
# @param collection_id [String]
|
147
|
-
# @return [String]
|
148
|
-
def self.parent_path project, database, collection_id
|
149
|
-
PARENT_PATH_TEMPLATE.render(
|
150
|
-
:"project" => project,
|
151
|
-
:"database" => database,
|
152
|
-
:"collection_id" => collection_id
|
157
|
+
:"collection" => collection,
|
158
|
+
:"index" => index
|
153
159
|
)
|
154
160
|
end
|
155
161
|
|
@@ -205,6 +211,18 @@ module Google
|
|
205
211
|
|
206
212
|
credentials ||= Google::Cloud::Firestore::Admin::V1::Credentials.default
|
207
213
|
|
214
|
+
@operations_client = OperationsClient.new(
|
215
|
+
credentials: credentials,
|
216
|
+
scopes: scopes,
|
217
|
+
client_config: client_config,
|
218
|
+
timeout: timeout,
|
219
|
+
lib_name: lib_name,
|
220
|
+
service_address: service_address,
|
221
|
+
service_port: service_port,
|
222
|
+
lib_version: lib_version,
|
223
|
+
metadata: metadata,
|
224
|
+
)
|
225
|
+
|
208
226
|
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
209
227
|
updater_proc = Google::Cloud::Firestore::Admin::V1::Credentials.new(credentials).updater_proc
|
210
228
|
end
|
@@ -230,6 +248,9 @@ module Google
|
|
230
248
|
google_api_client.freeze
|
231
249
|
|
232
250
|
headers = { :"x-goog-api-client" => google_api_client }
|
251
|
+
if credentials.respond_to?(:quota_project_id) && credentials.quota_project_id
|
252
|
+
headers[:"x-goog-user-project"] = credentials.quota_project_id
|
253
|
+
end
|
233
254
|
headers.merge!(metadata) unless metadata.nil?
|
234
255
|
client_config_file = Pathname.new(__dir__).join(
|
235
256
|
"firestore_admin_client_config.json"
|
@@ -262,6 +283,22 @@ module Google
|
|
262
283
|
&Google::Firestore::Admin::V1::FirestoreAdmin::Stub.method(:new)
|
263
284
|
)
|
264
285
|
|
286
|
+
@delete_index = Google::Gax.create_api_call(
|
287
|
+
@firestore_admin_stub.method(:delete_index),
|
288
|
+
defaults["delete_index"],
|
289
|
+
exception_transformer: exception_transformer,
|
290
|
+
params_extractor: proc do |request|
|
291
|
+
{'name' => request.name}
|
292
|
+
end
|
293
|
+
)
|
294
|
+
@update_field = Google::Gax.create_api_call(
|
295
|
+
@firestore_admin_stub.method(:update_field),
|
296
|
+
defaults["update_field"],
|
297
|
+
exception_transformer: exception_transformer,
|
298
|
+
params_extractor: proc do |request|
|
299
|
+
{'field.name' => request.field.name}
|
300
|
+
end
|
301
|
+
)
|
265
302
|
@create_index = Google::Gax.create_api_call(
|
266
303
|
@firestore_admin_stub.method(:create_index),
|
267
304
|
defaults["create_index"],
|
@@ -286,20 +323,20 @@ module Google
|
|
286
323
|
{'name' => request.name}
|
287
324
|
end
|
288
325
|
)
|
289
|
-
@
|
290
|
-
@firestore_admin_stub.method(:
|
291
|
-
defaults["
|
326
|
+
@get_field = Google::Gax.create_api_call(
|
327
|
+
@firestore_admin_stub.method(:get_field),
|
328
|
+
defaults["get_field"],
|
292
329
|
exception_transformer: exception_transformer,
|
293
330
|
params_extractor: proc do |request|
|
294
331
|
{'name' => request.name}
|
295
332
|
end
|
296
333
|
)
|
297
|
-
@
|
298
|
-
@firestore_admin_stub.method(:
|
299
|
-
defaults["
|
334
|
+
@list_fields = Google::Gax.create_api_call(
|
335
|
+
@firestore_admin_stub.method(:list_fields),
|
336
|
+
defaults["list_fields"],
|
300
337
|
exception_transformer: exception_transformer,
|
301
338
|
params_extractor: proc do |request|
|
302
|
-
{'
|
339
|
+
{'parent' => request.parent}
|
303
340
|
end
|
304
341
|
)
|
305
342
|
@export_documents = Google::Gax.create_api_call(
|
@@ -310,34 +347,132 @@ module Google
|
|
310
347
|
{'name' => request.name}
|
311
348
|
end
|
312
349
|
)
|
313
|
-
@
|
314
|
-
@firestore_admin_stub.method(:
|
315
|
-
defaults["
|
350
|
+
@import_documents = Google::Gax.create_api_call(
|
351
|
+
@firestore_admin_stub.method(:import_documents),
|
352
|
+
defaults["import_documents"],
|
316
353
|
exception_transformer: exception_transformer,
|
317
354
|
params_extractor: proc do |request|
|
318
355
|
{'name' => request.name}
|
319
356
|
end
|
320
357
|
)
|
321
|
-
@list_fields = Google::Gax.create_api_call(
|
322
|
-
@firestore_admin_stub.method(:list_fields),
|
323
|
-
defaults["list_fields"],
|
324
|
-
exception_transformer: exception_transformer,
|
325
|
-
params_extractor: proc do |request|
|
326
|
-
{'parent' => request.parent}
|
327
|
-
end
|
328
|
-
)
|
329
|
-
@update_field = Google::Gax.create_api_call(
|
330
|
-
@firestore_admin_stub.method(:update_field),
|
331
|
-
defaults["update_field"],
|
332
|
-
exception_transformer: exception_transformer,
|
333
|
-
params_extractor: proc do |request|
|
334
|
-
{'field.name' => request.field.name}
|
335
|
-
end
|
336
|
-
)
|
337
358
|
end
|
338
359
|
|
339
360
|
# Service calls
|
340
361
|
|
362
|
+
# Deletes a composite index.
|
363
|
+
#
|
364
|
+
# @param name [String]
|
365
|
+
# Required. A name of the form
|
366
|
+
# `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
|
367
|
+
# @param options [Google::Gax::CallOptions]
|
368
|
+
# Overrides the default settings for this call, e.g, timeout,
|
369
|
+
# retries, etc.
|
370
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
371
|
+
# @yieldparam result []
|
372
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
373
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
374
|
+
# @example
|
375
|
+
# require "google/cloud/firestore/admin"
|
376
|
+
#
|
377
|
+
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
378
|
+
# formatted_name = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.index_path("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]")
|
379
|
+
# firestore_admin_client.delete_index(formatted_name)
|
380
|
+
|
381
|
+
def delete_index \
|
382
|
+
name,
|
383
|
+
options: nil,
|
384
|
+
&block
|
385
|
+
req = {
|
386
|
+
name: name
|
387
|
+
}.delete_if { |_, v| v.nil? }
|
388
|
+
req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::DeleteIndexRequest)
|
389
|
+
@delete_index.call(req, options, &block)
|
390
|
+
nil
|
391
|
+
end
|
392
|
+
|
393
|
+
# Updates a field configuration. Currently, field updates apply only to
|
394
|
+
# single field index configuration. However, calls to
|
395
|
+
# {Google::Firestore::Admin::V1::FirestoreAdmin::UpdateField FirestoreAdmin::UpdateField} should provide a field mask to avoid
|
396
|
+
# changing any configuration that the caller isn't aware of. The field mask
|
397
|
+
# should be specified as: `{ paths: "index_config" }`.
|
398
|
+
#
|
399
|
+
# This call returns a {Google::Longrunning::Operation} which may be used to
|
400
|
+
# track the status of the field update. The metadata for
|
401
|
+
# the operation will be the type {Google::Firestore::Admin::V1::FieldOperationMetadata FieldOperationMetadata}.
|
402
|
+
#
|
403
|
+
# To configure the default field settings for the database, use
|
404
|
+
# the special `Field` with resource name:
|
405
|
+
# `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`.
|
406
|
+
#
|
407
|
+
# @param field [Google::Firestore::Admin::V1::Field | Hash]
|
408
|
+
# Required. The field to be updated.
|
409
|
+
# A hash of the same form as `Google::Firestore::Admin::V1::Field`
|
410
|
+
# can also be provided.
|
411
|
+
# @param update_mask [Google::Protobuf::FieldMask | Hash]
|
412
|
+
# A mask, relative to the field. If specified, only configuration specified
|
413
|
+
# by this field_mask will be updated in the field.
|
414
|
+
# A hash of the same form as `Google::Protobuf::FieldMask`
|
415
|
+
# can also be provided.
|
416
|
+
# @param options [Google::Gax::CallOptions]
|
417
|
+
# Overrides the default settings for this call, e.g, timeout,
|
418
|
+
# retries, etc.
|
419
|
+
# @return [Google::Gax::Operation]
|
420
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
421
|
+
# @example
|
422
|
+
# require "google/cloud/firestore/admin"
|
423
|
+
#
|
424
|
+
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
425
|
+
#
|
426
|
+
# # TODO: Initialize `field`:
|
427
|
+
# field = {}
|
428
|
+
#
|
429
|
+
# # Register a callback during the method call.
|
430
|
+
# operation = firestore_admin_client.update_field(field) do |op|
|
431
|
+
# raise op.results.message if op.error?
|
432
|
+
# op_results = op.results
|
433
|
+
# # Process the results.
|
434
|
+
#
|
435
|
+
# metadata = op.metadata
|
436
|
+
# # Process the metadata.
|
437
|
+
# end
|
438
|
+
#
|
439
|
+
# # Or use the return value to register a callback.
|
440
|
+
# operation.on_done do |op|
|
441
|
+
# raise op.results.message if op.error?
|
442
|
+
# op_results = op.results
|
443
|
+
# # Process the results.
|
444
|
+
#
|
445
|
+
# metadata = op.metadata
|
446
|
+
# # Process the metadata.
|
447
|
+
# end
|
448
|
+
#
|
449
|
+
# # Manually reload the operation.
|
450
|
+
# operation.reload!
|
451
|
+
#
|
452
|
+
# # Or block until the operation completes, triggering callbacks on
|
453
|
+
# # completion.
|
454
|
+
# operation.wait_until_done!
|
455
|
+
|
456
|
+
def update_field \
|
457
|
+
field,
|
458
|
+
update_mask: nil,
|
459
|
+
options: nil
|
460
|
+
req = {
|
461
|
+
field: field,
|
462
|
+
update_mask: update_mask
|
463
|
+
}.delete_if { |_, v| v.nil? }
|
464
|
+
req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::UpdateFieldRequest)
|
465
|
+
operation = Google::Gax::Operation.new(
|
466
|
+
@update_field.call(req, options),
|
467
|
+
@operations_client,
|
468
|
+
Google::Firestore::Admin::V1::Field,
|
469
|
+
Google::Firestore::Admin::V1::FieldOperationMetadata,
|
470
|
+
call_options: options
|
471
|
+
)
|
472
|
+
operation.on_done { |operation| yield(operation) } if block_given?
|
473
|
+
operation
|
474
|
+
end
|
475
|
+
|
341
476
|
# Creates a composite index. This returns a {Google::Longrunning::Operation}
|
342
477
|
# which may be used to track the status of the creation. The metadata for
|
343
478
|
# the operation will be the type {Google::Firestore::Admin::V1::IndexOperationMetadata IndexOperationMetadata}.
|
@@ -352,32 +487,62 @@ module Google
|
|
352
487
|
# @param options [Google::Gax::CallOptions]
|
353
488
|
# Overrides the default settings for this call, e.g, timeout,
|
354
489
|
# retries, etc.
|
355
|
-
# @
|
356
|
-
# @yieldparam result [Google::Longrunning::Operation]
|
357
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
358
|
-
# @return [Google::Longrunning::Operation]
|
490
|
+
# @return [Google::Gax::Operation]
|
359
491
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
360
492
|
# @example
|
361
493
|
# require "google/cloud/firestore/admin"
|
362
494
|
#
|
363
495
|
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
364
|
-
# formatted_parent = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.
|
496
|
+
# formatted_parent = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.collection_group_path("[PROJECT]", "[DATABASE]", "[COLLECTION]")
|
365
497
|
#
|
366
498
|
# # TODO: Initialize `index`:
|
367
499
|
# index = {}
|
368
|
-
#
|
500
|
+
#
|
501
|
+
# # Register a callback during the method call.
|
502
|
+
# operation = firestore_admin_client.create_index(formatted_parent, index) do |op|
|
503
|
+
# raise op.results.message if op.error?
|
504
|
+
# op_results = op.results
|
505
|
+
# # Process the results.
|
506
|
+
#
|
507
|
+
# metadata = op.metadata
|
508
|
+
# # Process the metadata.
|
509
|
+
# end
|
510
|
+
#
|
511
|
+
# # Or use the return value to register a callback.
|
512
|
+
# operation.on_done do |op|
|
513
|
+
# raise op.results.message if op.error?
|
514
|
+
# op_results = op.results
|
515
|
+
# # Process the results.
|
516
|
+
#
|
517
|
+
# metadata = op.metadata
|
518
|
+
# # Process the metadata.
|
519
|
+
# end
|
520
|
+
#
|
521
|
+
# # Manually reload the operation.
|
522
|
+
# operation.reload!
|
523
|
+
#
|
524
|
+
# # Or block until the operation completes, triggering callbacks on
|
525
|
+
# # completion.
|
526
|
+
# operation.wait_until_done!
|
369
527
|
|
370
528
|
def create_index \
|
371
529
|
parent,
|
372
530
|
index,
|
373
|
-
options: nil
|
374
|
-
&block
|
531
|
+
options: nil
|
375
532
|
req = {
|
376
533
|
parent: parent,
|
377
534
|
index: index
|
378
535
|
}.delete_if { |_, v| v.nil? }
|
379
536
|
req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::CreateIndexRequest)
|
380
|
-
|
537
|
+
operation = Google::Gax::Operation.new(
|
538
|
+
@create_index.call(req, options),
|
539
|
+
@operations_client,
|
540
|
+
Google::Firestore::Admin::V1::Index,
|
541
|
+
Google::Firestore::Admin::V1::IndexOperationMetadata,
|
542
|
+
call_options: options
|
543
|
+
)
|
544
|
+
operation.on_done { |operation| yield(operation) } if block_given?
|
545
|
+
operation
|
381
546
|
end
|
382
547
|
|
383
548
|
# Lists composite indexes.
|
@@ -409,7 +574,7 @@ module Google
|
|
409
574
|
# require "google/cloud/firestore/admin"
|
410
575
|
#
|
411
576
|
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
412
|
-
# formatted_parent = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.
|
577
|
+
# formatted_parent = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.collection_group_path("[PROJECT]", "[DATABASE]", "[COLLECTION]")
|
413
578
|
#
|
414
579
|
# # Iterate over all results.
|
415
580
|
# firestore_admin_client.list_indexes(formatted_parent).each do |element|
|
@@ -456,7 +621,7 @@ module Google
|
|
456
621
|
# require "google/cloud/firestore/admin"
|
457
622
|
#
|
458
623
|
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
459
|
-
# formatted_name = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.index_path("[PROJECT]", "[DATABASE]", "[
|
624
|
+
# formatted_name = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.index_path("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]")
|
460
625
|
# response = firestore_admin_client.get_index(formatted_name)
|
461
626
|
|
462
627
|
def get_index \
|
@@ -470,138 +635,6 @@ module Google
|
|
470
635
|
@get_index.call(req, options, &block)
|
471
636
|
end
|
472
637
|
|
473
|
-
# Deletes a composite index.
|
474
|
-
#
|
475
|
-
# @param name [String]
|
476
|
-
# Required. A name of the form
|
477
|
-
# `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
|
478
|
-
# @param options [Google::Gax::CallOptions]
|
479
|
-
# Overrides the default settings for this call, e.g, timeout,
|
480
|
-
# retries, etc.
|
481
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
482
|
-
# @yieldparam result []
|
483
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
484
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
485
|
-
# @example
|
486
|
-
# require "google/cloud/firestore/admin"
|
487
|
-
#
|
488
|
-
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
489
|
-
# formatted_name = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.index_path("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[INDEX_ID]")
|
490
|
-
# firestore_admin_client.delete_index(formatted_name)
|
491
|
-
|
492
|
-
def delete_index \
|
493
|
-
name,
|
494
|
-
options: nil,
|
495
|
-
&block
|
496
|
-
req = {
|
497
|
-
name: name
|
498
|
-
}.delete_if { |_, v| v.nil? }
|
499
|
-
req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::DeleteIndexRequest)
|
500
|
-
@delete_index.call(req, options, &block)
|
501
|
-
nil
|
502
|
-
end
|
503
|
-
|
504
|
-
# Imports documents into Google Cloud Firestore. Existing documents with the
|
505
|
-
# same name are overwritten. The import occurs in the background and its
|
506
|
-
# progress can be monitored and managed via the Operation resource that is
|
507
|
-
# created. If an ImportDocuments operation is cancelled, it is possible
|
508
|
-
# that a subset of the data has already been imported to Cloud Firestore.
|
509
|
-
#
|
510
|
-
# @param name [String]
|
511
|
-
# Required. Database to import into. Should be of the form:
|
512
|
-
# `projects/{project_id}/databases/{database_id}`.
|
513
|
-
# @param collection_ids [Array<String>]
|
514
|
-
# Which collection ids to import. Unspecified means all collections included
|
515
|
-
# in the import.
|
516
|
-
# @param input_uri_prefix [String]
|
517
|
-
# Location of the exported files.
|
518
|
-
# This must match the output_uri_prefix of an ExportDocumentsResponse from
|
519
|
-
# an export that has completed successfully.
|
520
|
-
# See:
|
521
|
-
# {Google::Firestore::Admin::V1::ExportDocumentsResponse#output_uri_prefix}.
|
522
|
-
# @param options [Google::Gax::CallOptions]
|
523
|
-
# Overrides the default settings for this call, e.g, timeout,
|
524
|
-
# retries, etc.
|
525
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
526
|
-
# @yieldparam result [Google::Longrunning::Operation]
|
527
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
528
|
-
# @return [Google::Longrunning::Operation]
|
529
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
530
|
-
# @example
|
531
|
-
# require "google/cloud/firestore/admin"
|
532
|
-
#
|
533
|
-
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
534
|
-
# formatted_name = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.database_path("[PROJECT]", "[DATABASE]")
|
535
|
-
# response = firestore_admin_client.import_documents(formatted_name)
|
536
|
-
|
537
|
-
def import_documents \
|
538
|
-
name,
|
539
|
-
collection_ids: nil,
|
540
|
-
input_uri_prefix: nil,
|
541
|
-
options: nil,
|
542
|
-
&block
|
543
|
-
req = {
|
544
|
-
name: name,
|
545
|
-
collection_ids: collection_ids,
|
546
|
-
input_uri_prefix: input_uri_prefix
|
547
|
-
}.delete_if { |_, v| v.nil? }
|
548
|
-
req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::ImportDocumentsRequest)
|
549
|
-
@import_documents.call(req, options, &block)
|
550
|
-
end
|
551
|
-
|
552
|
-
# Exports a copy of all or a subset of documents from Google Cloud Firestore
|
553
|
-
# to another storage system, such as Google Cloud Storage. Recent updates to
|
554
|
-
# documents may not be reflected in the export. The export occurs in the
|
555
|
-
# background and its progress can be monitored and managed via the
|
556
|
-
# Operation resource that is created. The output of an export may only be
|
557
|
-
# used once the associated operation is done. If an export operation is
|
558
|
-
# cancelled before completion it may leave partial data behind in Google
|
559
|
-
# Cloud Storage.
|
560
|
-
#
|
561
|
-
# @param name [String]
|
562
|
-
# Required. Database to export. Should be of the form:
|
563
|
-
# `projects/{project_id}/databases/{database_id}`.
|
564
|
-
# @param collection_ids [Array<String>]
|
565
|
-
# Which collection ids to export. Unspecified means all collections.
|
566
|
-
# @param output_uri_prefix [String]
|
567
|
-
# The output URI. Currently only supports Google Cloud Storage URIs of the
|
568
|
-
# form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name
|
569
|
-
# of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional
|
570
|
-
# Google Cloud Storage namespace path. When
|
571
|
-
# choosing a name, be sure to consider Google Cloud Storage naming
|
572
|
-
# guidelines: https://cloud.google.com/storage/docs/naming.
|
573
|
-
# If the URI is a bucket (without a namespace path), a prefix will be
|
574
|
-
# generated based on the start time.
|
575
|
-
# @param options [Google::Gax::CallOptions]
|
576
|
-
# Overrides the default settings for this call, e.g, timeout,
|
577
|
-
# retries, etc.
|
578
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
579
|
-
# @yieldparam result [Google::Longrunning::Operation]
|
580
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
581
|
-
# @return [Google::Longrunning::Operation]
|
582
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
583
|
-
# @example
|
584
|
-
# require "google/cloud/firestore/admin"
|
585
|
-
#
|
586
|
-
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
587
|
-
# formatted_name = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.database_path("[PROJECT]", "[DATABASE]")
|
588
|
-
# response = firestore_admin_client.export_documents(formatted_name)
|
589
|
-
|
590
|
-
def export_documents \
|
591
|
-
name,
|
592
|
-
collection_ids: nil,
|
593
|
-
output_uri_prefix: nil,
|
594
|
-
options: nil,
|
595
|
-
&block
|
596
|
-
req = {
|
597
|
-
name: name,
|
598
|
-
collection_ids: collection_ids,
|
599
|
-
output_uri_prefix: output_uri_prefix
|
600
|
-
}.delete_if { |_, v| v.nil? }
|
601
|
-
req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::ExportDocumentsRequest)
|
602
|
-
@export_documents.call(req, options, &block)
|
603
|
-
end
|
604
|
-
|
605
638
|
# Gets the metadata and configuration for a Field.
|
606
639
|
#
|
607
640
|
# @param name [String]
|
@@ -619,7 +652,7 @@ module Google
|
|
619
652
|
# require "google/cloud/firestore/admin"
|
620
653
|
#
|
621
654
|
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
622
|
-
# formatted_name = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.field_path("[PROJECT]", "[DATABASE]", "[
|
655
|
+
# formatted_name = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.field_path("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]")
|
623
656
|
# response = firestore_admin_client.get_field(formatted_name)
|
624
657
|
|
625
658
|
def get_field \
|
@@ -671,7 +704,7 @@ module Google
|
|
671
704
|
# require "google/cloud/firestore/admin"
|
672
705
|
#
|
673
706
|
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
674
|
-
# formatted_parent = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.
|
707
|
+
# formatted_parent = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.collection_group_path("[PROJECT]", "[DATABASE]", "[COLLECTION]")
|
675
708
|
#
|
676
709
|
# # Iterate over all results.
|
677
710
|
# firestore_admin_client.list_fields(formatted_parent).each do |element|
|
@@ -701,57 +734,165 @@ module Google
|
|
701
734
|
@list_fields.call(req, options, &block)
|
702
735
|
end
|
703
736
|
|
704
|
-
#
|
705
|
-
#
|
706
|
-
#
|
707
|
-
#
|
708
|
-
#
|
737
|
+
# Exports a copy of all or a subset of documents from Google Cloud Firestore
|
738
|
+
# to another storage system, such as Google Cloud Storage. Recent updates to
|
739
|
+
# documents may not be reflected in the export. The export occurs in the
|
740
|
+
# background and its progress can be monitored and managed via the
|
741
|
+
# Operation resource that is created. The output of an export may only be
|
742
|
+
# used once the associated operation is done. If an export operation is
|
743
|
+
# cancelled before completion it may leave partial data behind in Google
|
744
|
+
# Cloud Storage.
|
709
745
|
#
|
710
|
-
#
|
711
|
-
#
|
712
|
-
#
|
746
|
+
# @param name [String]
|
747
|
+
# Required. Database to export. Should be of the form:
|
748
|
+
# `projects/{project_id}/databases/{database_id}`.
|
749
|
+
# @param collection_ids [Array<String>]
|
750
|
+
# Which collection ids to export. Unspecified means all collections.
|
751
|
+
# @param output_uri_prefix [String]
|
752
|
+
# The output URI. Currently only supports Google Cloud Storage URIs of the
|
753
|
+
# form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name
|
754
|
+
# of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional
|
755
|
+
# Google Cloud Storage namespace path. When
|
756
|
+
# choosing a name, be sure to consider Google Cloud Storage naming
|
757
|
+
# guidelines: https://cloud.google.com/storage/docs/naming.
|
758
|
+
# If the URI is a bucket (without a namespace path), a prefix will be
|
759
|
+
# generated based on the start time.
|
760
|
+
# @param options [Google::Gax::CallOptions]
|
761
|
+
# Overrides the default settings for this call, e.g, timeout,
|
762
|
+
# retries, etc.
|
763
|
+
# @return [Google::Gax::Operation]
|
764
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
765
|
+
# @example
|
766
|
+
# require "google/cloud/firestore/admin"
|
713
767
|
#
|
714
|
-
#
|
715
|
-
#
|
716
|
-
# `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`.
|
768
|
+
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
769
|
+
# formatted_name = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.database_path("[PROJECT]", "[DATABASE]")
|
717
770
|
#
|
718
|
-
#
|
719
|
-
#
|
720
|
-
#
|
721
|
-
#
|
722
|
-
#
|
723
|
-
#
|
724
|
-
#
|
725
|
-
#
|
726
|
-
#
|
771
|
+
# # Register a callback during the method call.
|
772
|
+
# operation = firestore_admin_client.export_documents(formatted_name) do |op|
|
773
|
+
# raise op.results.message if op.error?
|
774
|
+
# op_results = op.results
|
775
|
+
# # Process the results.
|
776
|
+
#
|
777
|
+
# metadata = op.metadata
|
778
|
+
# # Process the metadata.
|
779
|
+
# end
|
780
|
+
#
|
781
|
+
# # Or use the return value to register a callback.
|
782
|
+
# operation.on_done do |op|
|
783
|
+
# raise op.results.message if op.error?
|
784
|
+
# op_results = op.results
|
785
|
+
# # Process the results.
|
786
|
+
#
|
787
|
+
# metadata = op.metadata
|
788
|
+
# # Process the metadata.
|
789
|
+
# end
|
790
|
+
#
|
791
|
+
# # Manually reload the operation.
|
792
|
+
# operation.reload!
|
793
|
+
#
|
794
|
+
# # Or block until the operation completes, triggering callbacks on
|
795
|
+
# # completion.
|
796
|
+
# operation.wait_until_done!
|
797
|
+
|
798
|
+
def export_documents \
|
799
|
+
name,
|
800
|
+
collection_ids: nil,
|
801
|
+
output_uri_prefix: nil,
|
802
|
+
options: nil
|
803
|
+
req = {
|
804
|
+
name: name,
|
805
|
+
collection_ids: collection_ids,
|
806
|
+
output_uri_prefix: output_uri_prefix
|
807
|
+
}.delete_if { |_, v| v.nil? }
|
808
|
+
req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::ExportDocumentsRequest)
|
809
|
+
operation = Google::Gax::Operation.new(
|
810
|
+
@export_documents.call(req, options),
|
811
|
+
@operations_client,
|
812
|
+
Google::Firestore::Admin::V1::ExportDocumentsResponse,
|
813
|
+
Google::Firestore::Admin::V1::ExportDocumentsMetadata,
|
814
|
+
call_options: options
|
815
|
+
)
|
816
|
+
operation.on_done { |operation| yield(operation) } if block_given?
|
817
|
+
operation
|
818
|
+
end
|
819
|
+
|
820
|
+
# Imports documents into Google Cloud Firestore. Existing documents with the
|
821
|
+
# same name are overwritten. The import occurs in the background and its
|
822
|
+
# progress can be monitored and managed via the Operation resource that is
|
823
|
+
# created. If an ImportDocuments operation is cancelled, it is possible
|
824
|
+
# that a subset of the data has already been imported to Cloud Firestore.
|
825
|
+
#
|
826
|
+
# @param name [String]
|
827
|
+
# Required. Database to import into. Should be of the form:
|
828
|
+
# `projects/{project_id}/databases/{database_id}`.
|
829
|
+
# @param collection_ids [Array<String>]
|
830
|
+
# Which collection ids to import. Unspecified means all collections included
|
831
|
+
# in the import.
|
832
|
+
# @param input_uri_prefix [String]
|
833
|
+
# Location of the exported files.
|
834
|
+
# This must match the output_uri_prefix of an ExportDocumentsResponse from
|
835
|
+
# an export that has completed successfully.
|
836
|
+
# See:
|
837
|
+
# {Google::Firestore::Admin::V1::ExportDocumentsResponse#output_uri_prefix}.
|
727
838
|
# @param options [Google::Gax::CallOptions]
|
728
839
|
# Overrides the default settings for this call, e.g, timeout,
|
729
840
|
# retries, etc.
|
730
|
-
# @
|
731
|
-
# @yieldparam result [Google::Longrunning::Operation]
|
732
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
733
|
-
# @return [Google::Longrunning::Operation]
|
841
|
+
# @return [Google::Gax::Operation]
|
734
842
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
735
843
|
# @example
|
736
844
|
# require "google/cloud/firestore/admin"
|
737
845
|
#
|
738
846
|
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
847
|
+
# formatted_name = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.database_path("[PROJECT]", "[DATABASE]")
|
739
848
|
#
|
740
|
-
# #
|
741
|
-
#
|
742
|
-
#
|
849
|
+
# # Register a callback during the method call.
|
850
|
+
# operation = firestore_admin_client.import_documents(formatted_name) do |op|
|
851
|
+
# raise op.results.message if op.error?
|
852
|
+
# op_results = op.results
|
853
|
+
# # Process the results.
|
854
|
+
#
|
855
|
+
# metadata = op.metadata
|
856
|
+
# # Process the metadata.
|
857
|
+
# end
|
858
|
+
#
|
859
|
+
# # Or use the return value to register a callback.
|
860
|
+
# operation.on_done do |op|
|
861
|
+
# raise op.results.message if op.error?
|
862
|
+
# op_results = op.results
|
863
|
+
# # Process the results.
|
864
|
+
#
|
865
|
+
# metadata = op.metadata
|
866
|
+
# # Process the metadata.
|
867
|
+
# end
|
868
|
+
#
|
869
|
+
# # Manually reload the operation.
|
870
|
+
# operation.reload!
|
871
|
+
#
|
872
|
+
# # Or block until the operation completes, triggering callbacks on
|
873
|
+
# # completion.
|
874
|
+
# operation.wait_until_done!
|
743
875
|
|
744
|
-
def
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
876
|
+
def import_documents \
|
877
|
+
name,
|
878
|
+
collection_ids: nil,
|
879
|
+
input_uri_prefix: nil,
|
880
|
+
options: nil
|
749
881
|
req = {
|
750
|
-
|
751
|
-
|
882
|
+
name: name,
|
883
|
+
collection_ids: collection_ids,
|
884
|
+
input_uri_prefix: input_uri_prefix
|
752
885
|
}.delete_if { |_, v| v.nil? }
|
753
|
-
req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::
|
754
|
-
|
886
|
+
req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::ImportDocumentsRequest)
|
887
|
+
operation = Google::Gax::Operation.new(
|
888
|
+
@import_documents.call(req, options),
|
889
|
+
@operations_client,
|
890
|
+
Google::Protobuf::Empty,
|
891
|
+
Google::Firestore::Admin::V1::ImportDocumentsMetadata,
|
892
|
+
call_options: options
|
893
|
+
)
|
894
|
+
operation.on_done { |operation| yield(operation) } if block_given?
|
895
|
+
operation
|
755
896
|
end
|
756
897
|
end
|
757
898
|
end
|