google-cloud-firestore 1.4.0 → 1.4.1
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 +6 -0
- data/lib/google/cloud/firestore/admin/v1/firestore_admin_client.rb +375 -237
- data/lib/google/cloud/firestore/admin/v1/firestore_admin_client_config.json +14 -15
- data/lib/google/cloud/firestore/service.rb +15 -9
- data/lib/google/cloud/firestore/v1/firestore_client.rb +58 -120
- data/lib/google/cloud/firestore/v1/firestore_client_config.json +4 -5
- data/lib/google/cloud/firestore/v1beta1/firestore_client.rb +489 -551
- data/lib/google/cloud/firestore/v1beta1/firestore_client_config.json +28 -28
- data/lib/google/cloud/firestore/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c6817bc0ec1113059a7a310bf96f92272d0947d2602c511796c2c921c325f41
|
4
|
+
data.tar.gz: 2b0835c6d9d67b03b1bfc00b7d03fde70f2696612194d51b7dec55f64066b246
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c40af10bf4ffd742dc9b889d4591d23197526ab4b5f0246bcd5b166ac0b913aaff2e78c41b3ccf1d1a8328c1e59075cb317616e2bb655e4ad105a20a8df9c9a2
|
7
|
+
data.tar.gz: b4f8e9c5d553951f49b42013247f665dd454be9b93c2edb329b9e7ac223275b1828d004a123faa98e65d357c4692cfd2f5dc3ecdfb0702fce044a67c2dcc82bf
|
data/CHANGELOG.md
CHANGED
@@ -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
|
@@ -265,6 +283,22 @@ module Google
|
|
265
283
|
&Google::Firestore::Admin::V1::FirestoreAdmin::Stub.method(:new)
|
266
284
|
)
|
267
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
|
+
)
|
268
302
|
@create_index = Google::Gax.create_api_call(
|
269
303
|
@firestore_admin_stub.method(:create_index),
|
270
304
|
defaults["create_index"],
|
@@ -289,20 +323,20 @@ module Google
|
|
289
323
|
{'name' => request.name}
|
290
324
|
end
|
291
325
|
)
|
292
|
-
@
|
293
|
-
@firestore_admin_stub.method(:
|
294
|
-
defaults["
|
326
|
+
@get_field = Google::Gax.create_api_call(
|
327
|
+
@firestore_admin_stub.method(:get_field),
|
328
|
+
defaults["get_field"],
|
295
329
|
exception_transformer: exception_transformer,
|
296
330
|
params_extractor: proc do |request|
|
297
331
|
{'name' => request.name}
|
298
332
|
end
|
299
333
|
)
|
300
|
-
@
|
301
|
-
@firestore_admin_stub.method(:
|
302
|
-
defaults["
|
334
|
+
@list_fields = Google::Gax.create_api_call(
|
335
|
+
@firestore_admin_stub.method(:list_fields),
|
336
|
+
defaults["list_fields"],
|
303
337
|
exception_transformer: exception_transformer,
|
304
338
|
params_extractor: proc do |request|
|
305
|
-
{'
|
339
|
+
{'parent' => request.parent}
|
306
340
|
end
|
307
341
|
)
|
308
342
|
@export_documents = Google::Gax.create_api_call(
|
@@ -313,34 +347,132 @@ module Google
|
|
313
347
|
{'name' => request.name}
|
314
348
|
end
|
315
349
|
)
|
316
|
-
@
|
317
|
-
@firestore_admin_stub.method(:
|
318
|
-
defaults["
|
350
|
+
@import_documents = Google::Gax.create_api_call(
|
351
|
+
@firestore_admin_stub.method(:import_documents),
|
352
|
+
defaults["import_documents"],
|
319
353
|
exception_transformer: exception_transformer,
|
320
354
|
params_extractor: proc do |request|
|
321
355
|
{'name' => request.name}
|
322
356
|
end
|
323
357
|
)
|
324
|
-
@list_fields = Google::Gax.create_api_call(
|
325
|
-
@firestore_admin_stub.method(:list_fields),
|
326
|
-
defaults["list_fields"],
|
327
|
-
exception_transformer: exception_transformer,
|
328
|
-
params_extractor: proc do |request|
|
329
|
-
{'parent' => request.parent}
|
330
|
-
end
|
331
|
-
)
|
332
|
-
@update_field = Google::Gax.create_api_call(
|
333
|
-
@firestore_admin_stub.method(:update_field),
|
334
|
-
defaults["update_field"],
|
335
|
-
exception_transformer: exception_transformer,
|
336
|
-
params_extractor: proc do |request|
|
337
|
-
{'field.name' => request.field.name}
|
338
|
-
end
|
339
|
-
)
|
340
358
|
end
|
341
359
|
|
342
360
|
# Service calls
|
343
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
|
+
|
344
476
|
# Creates a composite index. This returns a {Google::Longrunning::Operation}
|
345
477
|
# which may be used to track the status of the creation. The metadata for
|
346
478
|
# the operation will be the type {Google::Firestore::Admin::V1::IndexOperationMetadata IndexOperationMetadata}.
|
@@ -355,32 +487,62 @@ module Google
|
|
355
487
|
# @param options [Google::Gax::CallOptions]
|
356
488
|
# Overrides the default settings for this call, e.g, timeout,
|
357
489
|
# retries, etc.
|
358
|
-
# @
|
359
|
-
# @yieldparam result [Google::Longrunning::Operation]
|
360
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
361
|
-
# @return [Google::Longrunning::Operation]
|
490
|
+
# @return [Google::Gax::Operation]
|
362
491
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
363
492
|
# @example
|
364
493
|
# require "google/cloud/firestore/admin"
|
365
494
|
#
|
366
495
|
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
367
|
-
# formatted_parent = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.
|
496
|
+
# formatted_parent = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.collection_group_path("[PROJECT]", "[DATABASE]", "[COLLECTION]")
|
368
497
|
#
|
369
498
|
# # TODO: Initialize `index`:
|
370
499
|
# index = {}
|
371
|
-
#
|
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!
|
372
527
|
|
373
528
|
def create_index \
|
374
529
|
parent,
|
375
530
|
index,
|
376
|
-
options: nil
|
377
|
-
&block
|
531
|
+
options: nil
|
378
532
|
req = {
|
379
533
|
parent: parent,
|
380
534
|
index: index
|
381
535
|
}.delete_if { |_, v| v.nil? }
|
382
536
|
req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::CreateIndexRequest)
|
383
|
-
|
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
|
384
546
|
end
|
385
547
|
|
386
548
|
# Lists composite indexes.
|
@@ -412,7 +574,7 @@ module Google
|
|
412
574
|
# require "google/cloud/firestore/admin"
|
413
575
|
#
|
414
576
|
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
415
|
-
# formatted_parent = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.
|
577
|
+
# formatted_parent = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.collection_group_path("[PROJECT]", "[DATABASE]", "[COLLECTION]")
|
416
578
|
#
|
417
579
|
# # Iterate over all results.
|
418
580
|
# firestore_admin_client.list_indexes(formatted_parent).each do |element|
|
@@ -459,7 +621,7 @@ module Google
|
|
459
621
|
# require "google/cloud/firestore/admin"
|
460
622
|
#
|
461
623
|
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
462
|
-
# 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]")
|
463
625
|
# response = firestore_admin_client.get_index(formatted_name)
|
464
626
|
|
465
627
|
def get_index \
|
@@ -473,138 +635,6 @@ module Google
|
|
473
635
|
@get_index.call(req, options, &block)
|
474
636
|
end
|
475
637
|
|
476
|
-
# Deletes a composite index.
|
477
|
-
#
|
478
|
-
# @param name [String]
|
479
|
-
# Required. A name of the form
|
480
|
-
# `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
|
481
|
-
# @param options [Google::Gax::CallOptions]
|
482
|
-
# Overrides the default settings for this call, e.g, timeout,
|
483
|
-
# retries, etc.
|
484
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
485
|
-
# @yieldparam result []
|
486
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
487
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
488
|
-
# @example
|
489
|
-
# require "google/cloud/firestore/admin"
|
490
|
-
#
|
491
|
-
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
492
|
-
# formatted_name = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.index_path("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[INDEX_ID]")
|
493
|
-
# firestore_admin_client.delete_index(formatted_name)
|
494
|
-
|
495
|
-
def delete_index \
|
496
|
-
name,
|
497
|
-
options: nil,
|
498
|
-
&block
|
499
|
-
req = {
|
500
|
-
name: name
|
501
|
-
}.delete_if { |_, v| v.nil? }
|
502
|
-
req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::DeleteIndexRequest)
|
503
|
-
@delete_index.call(req, options, &block)
|
504
|
-
nil
|
505
|
-
end
|
506
|
-
|
507
|
-
# Imports documents into Google Cloud Firestore. Existing documents with the
|
508
|
-
# same name are overwritten. The import occurs in the background and its
|
509
|
-
# progress can be monitored and managed via the Operation resource that is
|
510
|
-
# created. If an ImportDocuments operation is cancelled, it is possible
|
511
|
-
# that a subset of the data has already been imported to Cloud Firestore.
|
512
|
-
#
|
513
|
-
# @param name [String]
|
514
|
-
# Required. Database to import into. Should be of the form:
|
515
|
-
# `projects/{project_id}/databases/{database_id}`.
|
516
|
-
# @param collection_ids [Array<String>]
|
517
|
-
# Which collection ids to import. Unspecified means all collections included
|
518
|
-
# in the import.
|
519
|
-
# @param input_uri_prefix [String]
|
520
|
-
# Location of the exported files.
|
521
|
-
# This must match the output_uri_prefix of an ExportDocumentsResponse from
|
522
|
-
# an export that has completed successfully.
|
523
|
-
# See:
|
524
|
-
# {Google::Firestore::Admin::V1::ExportDocumentsResponse#output_uri_prefix}.
|
525
|
-
# @param options [Google::Gax::CallOptions]
|
526
|
-
# Overrides the default settings for this call, e.g, timeout,
|
527
|
-
# retries, etc.
|
528
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
529
|
-
# @yieldparam result [Google::Longrunning::Operation]
|
530
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
531
|
-
# @return [Google::Longrunning::Operation]
|
532
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
533
|
-
# @example
|
534
|
-
# require "google/cloud/firestore/admin"
|
535
|
-
#
|
536
|
-
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
537
|
-
# formatted_name = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.database_path("[PROJECT]", "[DATABASE]")
|
538
|
-
# response = firestore_admin_client.import_documents(formatted_name)
|
539
|
-
|
540
|
-
def import_documents \
|
541
|
-
name,
|
542
|
-
collection_ids: nil,
|
543
|
-
input_uri_prefix: nil,
|
544
|
-
options: nil,
|
545
|
-
&block
|
546
|
-
req = {
|
547
|
-
name: name,
|
548
|
-
collection_ids: collection_ids,
|
549
|
-
input_uri_prefix: input_uri_prefix
|
550
|
-
}.delete_if { |_, v| v.nil? }
|
551
|
-
req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::ImportDocumentsRequest)
|
552
|
-
@import_documents.call(req, options, &block)
|
553
|
-
end
|
554
|
-
|
555
|
-
# Exports a copy of all or a subset of documents from Google Cloud Firestore
|
556
|
-
# to another storage system, such as Google Cloud Storage. Recent updates to
|
557
|
-
# documents may not be reflected in the export. The export occurs in the
|
558
|
-
# background and its progress can be monitored and managed via the
|
559
|
-
# Operation resource that is created. The output of an export may only be
|
560
|
-
# used once the associated operation is done. If an export operation is
|
561
|
-
# cancelled before completion it may leave partial data behind in Google
|
562
|
-
# Cloud Storage.
|
563
|
-
#
|
564
|
-
# @param name [String]
|
565
|
-
# Required. Database to export. Should be of the form:
|
566
|
-
# `projects/{project_id}/databases/{database_id}`.
|
567
|
-
# @param collection_ids [Array<String>]
|
568
|
-
# Which collection ids to export. Unspecified means all collections.
|
569
|
-
# @param output_uri_prefix [String]
|
570
|
-
# The output URI. Currently only supports Google Cloud Storage URIs of the
|
571
|
-
# form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name
|
572
|
-
# of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional
|
573
|
-
# Google Cloud Storage namespace path. When
|
574
|
-
# choosing a name, be sure to consider Google Cloud Storage naming
|
575
|
-
# guidelines: https://cloud.google.com/storage/docs/naming.
|
576
|
-
# If the URI is a bucket (without a namespace path), a prefix will be
|
577
|
-
# generated based on the start time.
|
578
|
-
# @param options [Google::Gax::CallOptions]
|
579
|
-
# Overrides the default settings for this call, e.g, timeout,
|
580
|
-
# retries, etc.
|
581
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
582
|
-
# @yieldparam result [Google::Longrunning::Operation]
|
583
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
584
|
-
# @return [Google::Longrunning::Operation]
|
585
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
586
|
-
# @example
|
587
|
-
# require "google/cloud/firestore/admin"
|
588
|
-
#
|
589
|
-
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
590
|
-
# formatted_name = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.database_path("[PROJECT]", "[DATABASE]")
|
591
|
-
# response = firestore_admin_client.export_documents(formatted_name)
|
592
|
-
|
593
|
-
def export_documents \
|
594
|
-
name,
|
595
|
-
collection_ids: nil,
|
596
|
-
output_uri_prefix: nil,
|
597
|
-
options: nil,
|
598
|
-
&block
|
599
|
-
req = {
|
600
|
-
name: name,
|
601
|
-
collection_ids: collection_ids,
|
602
|
-
output_uri_prefix: output_uri_prefix
|
603
|
-
}.delete_if { |_, v| v.nil? }
|
604
|
-
req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::ExportDocumentsRequest)
|
605
|
-
@export_documents.call(req, options, &block)
|
606
|
-
end
|
607
|
-
|
608
638
|
# Gets the metadata and configuration for a Field.
|
609
639
|
#
|
610
640
|
# @param name [String]
|
@@ -622,7 +652,7 @@ module Google
|
|
622
652
|
# require "google/cloud/firestore/admin"
|
623
653
|
#
|
624
654
|
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
625
|
-
# 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]")
|
626
656
|
# response = firestore_admin_client.get_field(formatted_name)
|
627
657
|
|
628
658
|
def get_field \
|
@@ -674,7 +704,7 @@ module Google
|
|
674
704
|
# require "google/cloud/firestore/admin"
|
675
705
|
#
|
676
706
|
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
677
|
-
# formatted_parent = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.
|
707
|
+
# formatted_parent = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.collection_group_path("[PROJECT]", "[DATABASE]", "[COLLECTION]")
|
678
708
|
#
|
679
709
|
# # Iterate over all results.
|
680
710
|
# firestore_admin_client.list_fields(formatted_parent).each do |element|
|
@@ -704,57 +734,165 @@ module Google
|
|
704
734
|
@list_fields.call(req, options, &block)
|
705
735
|
end
|
706
736
|
|
707
|
-
#
|
708
|
-
#
|
709
|
-
#
|
710
|
-
#
|
711
|
-
#
|
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.
|
712
745
|
#
|
713
|
-
#
|
714
|
-
#
|
715
|
-
#
|
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"
|
716
767
|
#
|
717
|
-
#
|
718
|
-
#
|
719
|
-
# `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]")
|
720
770
|
#
|
721
|
-
#
|
722
|
-
#
|
723
|
-
#
|
724
|
-
#
|
725
|
-
#
|
726
|
-
#
|
727
|
-
#
|
728
|
-
#
|
729
|
-
#
|
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}.
|
730
838
|
# @param options [Google::Gax::CallOptions]
|
731
839
|
# Overrides the default settings for this call, e.g, timeout,
|
732
840
|
# retries, etc.
|
733
|
-
# @
|
734
|
-
# @yieldparam result [Google::Longrunning::Operation]
|
735
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
736
|
-
# @return [Google::Longrunning::Operation]
|
841
|
+
# @return [Google::Gax::Operation]
|
737
842
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
738
843
|
# @example
|
739
844
|
# require "google/cloud/firestore/admin"
|
740
845
|
#
|
741
846
|
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
847
|
+
# formatted_name = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.database_path("[PROJECT]", "[DATABASE]")
|
742
848
|
#
|
743
|
-
# #
|
744
|
-
#
|
745
|
-
#
|
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!
|
746
875
|
|
747
|
-
def
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
876
|
+
def import_documents \
|
877
|
+
name,
|
878
|
+
collection_ids: nil,
|
879
|
+
input_uri_prefix: nil,
|
880
|
+
options: nil
|
752
881
|
req = {
|
753
|
-
|
754
|
-
|
882
|
+
name: name,
|
883
|
+
collection_ids: collection_ids,
|
884
|
+
input_uri_prefix: input_uri_prefix
|
755
885
|
}.delete_if { |_, v| v.nil? }
|
756
|
-
req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::
|
757
|
-
|
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
|
758
896
|
end
|
759
897
|
end
|
760
898
|
end
|