google-cloud-firestore-admin-v1 1.0.1 → 1.2.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.
@@ -221,14 +221,26 @@ module Google
221
221
  endpoint: @config.endpoint,
222
222
  endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
223
223
  universe_domain: @config.universe_domain,
224
- credentials: credentials
224
+ credentials: credentials,
225
+ logger: @config.logger
225
226
  )
226
227
 
228
+ @firestore_admin_stub.logger(stub: true)&.info do |entry|
229
+ entry.set_system_name
230
+ entry.set_service
231
+ entry.message = "Created client for #{entry.service}"
232
+ entry.set_credentials_fields credentials
233
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
234
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
235
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
236
+ end
237
+
227
238
  @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
228
239
  config.credentials = credentials
229
240
  config.quota_project = @quota_project_id
230
241
  config.endpoint = @firestore_admin_stub.endpoint
231
242
  config.universe_domain = @firestore_admin_stub.universe_domain
243
+ config.logger = @firestore_admin_stub.logger if config.respond_to? :logger=
232
244
  end
233
245
  end
234
246
 
@@ -246,6 +258,15 @@ module Google
246
258
  #
247
259
  attr_reader :location_client
248
260
 
261
+ ##
262
+ # The logger used for request/response debug logging.
263
+ #
264
+ # @return [Logger]
265
+ #
266
+ def logger
267
+ @firestore_admin_stub.logger
268
+ end
269
+
249
270
  # Service calls
250
271
 
251
272
  ##
@@ -336,7 +357,7 @@ module Google
336
357
  @firestore_admin_stub.create_index request, options do |result, operation|
337
358
  result = ::Gapic::Operation.new result, @operations_client, options: options
338
359
  yield result, operation if block_given?
339
- return result
360
+ throw :response, result
340
361
  end
341
362
  rescue ::Gapic::Rest::Error => e
342
363
  raise ::Google::Cloud::Error.from_error(e)
@@ -429,7 +450,7 @@ module Google
429
450
  @firestore_admin_stub.list_indexes request, options do |result, operation|
430
451
  result = ::Gapic::Rest::PagedEnumerable.new @firestore_admin_stub, :list_indexes, "indexes", request, result, options
431
452
  yield result, operation if block_given?
432
- return result
453
+ throw :response, result
433
454
  end
434
455
  rescue ::Gapic::Rest::Error => e
435
456
  raise ::Google::Cloud::Error.from_error(e)
@@ -509,7 +530,6 @@ module Google
509
530
 
510
531
  @firestore_admin_stub.get_index request, options do |result, operation|
511
532
  yield result, operation if block_given?
512
- return result
513
533
  end
514
534
  rescue ::Gapic::Rest::Error => e
515
535
  raise ::Google::Cloud::Error.from_error(e)
@@ -589,7 +609,6 @@ module Google
589
609
 
590
610
  @firestore_admin_stub.delete_index request, options do |result, operation|
591
611
  yield result, operation if block_given?
592
- return result
593
612
  end
594
613
  rescue ::Gapic::Rest::Error => e
595
614
  raise ::Google::Cloud::Error.from_error(e)
@@ -669,7 +688,6 @@ module Google
669
688
 
670
689
  @firestore_admin_stub.get_field request, options do |result, operation|
671
690
  yield result, operation if block_given?
672
- return result
673
691
  end
674
692
  rescue ::Gapic::Rest::Error => e
675
693
  raise ::Google::Cloud::Error.from_error(e)
@@ -774,7 +792,7 @@ module Google
774
792
  @firestore_admin_stub.update_field request, options do |result, operation|
775
793
  result = ::Gapic::Operation.new result, @operations_client, options: options
776
794
  yield result, operation if block_given?
777
- return result
795
+ throw :response, result
778
796
  end
779
797
  rescue ::Gapic::Rest::Error => e
780
798
  raise ::Google::Cloud::Error.from_error(e)
@@ -881,7 +899,7 @@ module Google
881
899
  @firestore_admin_stub.list_fields request, options do |result, operation|
882
900
  result = ::Gapic::Rest::PagedEnumerable.new @firestore_admin_stub, :list_fields, "fields", request, result, options
883
901
  yield result, operation if block_given?
884
- return result
902
+ throw :response, result
885
903
  end
886
904
  rescue ::Gapic::Rest::Error => e
887
905
  raise ::Google::Cloud::Error.from_error(e)
@@ -919,8 +937,8 @@ module Google
919
937
  # Required. Database to export. Should be of the form:
920
938
  # `projects/{project_id}/databases/{database_id}`.
921
939
  # @param collection_ids [::Array<::String>]
922
- # Which collection ids to export. Unspecified means all collections. Each
923
- # collection id in this list must be unique.
940
+ # Which collection IDs to export. Unspecified means all collections. Each
941
+ # collection ID in this list must be unique.
924
942
  # @param output_uri_prefix [::String]
925
943
  # The output URI. Currently only supports Google Cloud Storage URIs of the
926
944
  # form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name
@@ -1006,7 +1024,7 @@ module Google
1006
1024
  @firestore_admin_stub.export_documents request, options do |result, operation|
1007
1025
  result = ::Gapic::Operation.new result, @operations_client, options: options
1008
1026
  yield result, operation if block_given?
1009
- return result
1027
+ throw :response, result
1010
1028
  end
1011
1029
  rescue ::Gapic::Rest::Error => e
1012
1030
  raise ::Google::Cloud::Error.from_error(e)
@@ -1038,8 +1056,8 @@ module Google
1038
1056
  # Required. Database to import into. Should be of the form:
1039
1057
  # `projects/{project_id}/databases/{database_id}`.
1040
1058
  # @param collection_ids [::Array<::String>]
1041
- # Which collection ids to import. Unspecified means all collections included
1042
- # in the import. Each collection id in this list must be unique.
1059
+ # Which collection IDs to import. Unspecified means all collections included
1060
+ # in the import. Each collection ID in this list must be unique.
1043
1061
  # @param input_uri_prefix [::String]
1044
1062
  # Location of the exported files.
1045
1063
  # This must match the output_uri_prefix of an ExportDocumentsResponse from
@@ -1114,7 +1132,7 @@ module Google
1114
1132
  @firestore_admin_stub.import_documents request, options do |result, operation|
1115
1133
  result = ::Gapic::Operation.new result, @operations_client, options: options
1116
1134
  yield result, operation if block_given?
1117
- return result
1135
+ throw :response, result
1118
1136
  end
1119
1137
  rescue ::Gapic::Rest::Error => e
1120
1138
  raise ::Google::Cloud::Error.from_error(e)
@@ -1225,7 +1243,7 @@ module Google
1225
1243
  @firestore_admin_stub.bulk_delete_documents request, options do |result, operation|
1226
1244
  result = ::Gapic::Operation.new result, @operations_client, options: options
1227
1245
  yield result, operation if block_given?
1228
- return result
1246
+ throw :response, result
1229
1247
  end
1230
1248
  rescue ::Gapic::Rest::Error => e
1231
1249
  raise ::Google::Cloud::Error.from_error(e)
@@ -1262,7 +1280,7 @@ module Google
1262
1280
  # with first character a letter and the last a letter or a number. Must not
1263
1281
  # be UUID-like /[0-9a-f]\\{8}(-[0-9a-f]\\{4})\\{3}-[0-9a-f]\\{12}/.
1264
1282
  #
1265
- # "(default)" database id is also valid.
1283
+ # "(default)" database ID is also valid.
1266
1284
  # @yield [result, operation] Access the result along with the TransportOperation object
1267
1285
  # @yieldparam result [::Gapic::Operation]
1268
1286
  # @yieldparam operation [::Gapic::Rest::TransportOperation]
@@ -1324,7 +1342,7 @@ module Google
1324
1342
  @firestore_admin_stub.create_database request, options do |result, operation|
1325
1343
  result = ::Gapic::Operation.new result, @operations_client, options: options
1326
1344
  yield result, operation if block_given?
1327
- return result
1345
+ throw :response, result
1328
1346
  end
1329
1347
  rescue ::Gapic::Rest::Error => e
1330
1348
  raise ::Google::Cloud::Error.from_error(e)
@@ -1404,7 +1422,6 @@ module Google
1404
1422
 
1405
1423
  @firestore_admin_stub.get_database request, options do |result, operation|
1406
1424
  yield result, operation if block_given?
1407
- return result
1408
1425
  end
1409
1426
  rescue ::Gapic::Rest::Error => e
1410
1427
  raise ::Google::Cloud::Error.from_error(e)
@@ -1486,7 +1503,6 @@ module Google
1486
1503
 
1487
1504
  @firestore_admin_stub.list_databases request, options do |result, operation|
1488
1505
  yield result, operation if block_given?
1489
- return result
1490
1506
  end
1491
1507
  rescue ::Gapic::Rest::Error => e
1492
1508
  raise ::Google::Cloud::Error.from_error(e)
@@ -1575,7 +1591,7 @@ module Google
1575
1591
  @firestore_admin_stub.update_database request, options do |result, operation|
1576
1592
  result = ::Gapic::Operation.new result, @operations_client, options: options
1577
1593
  yield result, operation if block_given?
1578
- return result
1594
+ throw :response, result
1579
1595
  end
1580
1596
  rescue ::Gapic::Rest::Error => e
1581
1597
  raise ::Google::Cloud::Error.from_error(e)
@@ -1667,7 +1683,7 @@ module Google
1667
1683
  @firestore_admin_stub.delete_database request, options do |result, operation|
1668
1684
  result = ::Gapic::Operation.new result, @operations_client, options: options
1669
1685
  yield result, operation if block_given?
1670
- return result
1686
+ throw :response, result
1671
1687
  end
1672
1688
  rescue ::Gapic::Rest::Error => e
1673
1689
  raise ::Google::Cloud::Error.from_error(e)
@@ -1748,7 +1764,6 @@ module Google
1748
1764
 
1749
1765
  @firestore_admin_stub.get_backup request, options do |result, operation|
1750
1766
  yield result, operation if block_given?
1751
- return result
1752
1767
  end
1753
1768
  rescue ::Gapic::Rest::Error => e
1754
1769
  raise ::Google::Cloud::Error.from_error(e)
@@ -1832,7 +1847,6 @@ module Google
1832
1847
 
1833
1848
  @firestore_admin_stub.list_backups request, options do |result, operation|
1834
1849
  yield result, operation if block_given?
1835
- return result
1836
1850
  end
1837
1851
  rescue ::Gapic::Rest::Error => e
1838
1852
  raise ::Google::Cloud::Error.from_error(e)
@@ -1913,7 +1927,6 @@ module Google
1913
1927
 
1914
1928
  @firestore_admin_stub.delete_backup request, options do |result, operation|
1915
1929
  yield result, operation if block_given?
1916
- return result
1917
1930
  end
1918
1931
  rescue ::Gapic::Rest::Error => e
1919
1932
  raise ::Google::Cloud::Error.from_error(e)
@@ -1948,7 +1961,7 @@ module Google
1948
1961
  # @param options [::Gapic::CallOptions, ::Hash]
1949
1962
  # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1950
1963
  #
1951
- # @overload restore_database(parent: nil, database_id: nil, backup: nil)
1964
+ # @overload restore_database(parent: nil, database_id: nil, backup: nil, encryption_config: nil)
1952
1965
  # Pass arguments to `restore_database` via keyword arguments. Note that at
1953
1966
  # least one keyword argument is required. To specify no parameters, or to keep all
1954
1967
  # the default parameter values, pass an empty Hash as a request object (see above).
@@ -1958,19 +1971,28 @@ module Google
1958
1971
  # `projects/{project_id}`.
1959
1972
  # @param database_id [::String]
1960
1973
  # Required. The ID to use for the database, which will become the final
1961
- # component of the database's resource name. This database id must not be
1974
+ # component of the database's resource name. This database ID must not be
1962
1975
  # associated with an existing database.
1963
1976
  #
1964
1977
  # This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
1965
1978
  # with first character a letter and the last a letter or a number. Must not
1966
1979
  # be UUID-like /[0-9a-f]\\{8}(-[0-9a-f]\\{4})\\{3}-[0-9a-f]\\{12}/.
1967
1980
  #
1968
- # "(default)" database id is also valid.
1981
+ # "(default)" database ID is also valid.
1969
1982
  # @param backup [::String]
1970
1983
  # Required. Backup to restore from. Must be from the same project as the
1971
1984
  # parent.
1972
1985
  #
1986
+ # The restored database will be created in the same location as the source
1987
+ # backup.
1988
+ #
1973
1989
  # Format is: `projects/{project_id}/locations/{location}/backups/{backup}`
1990
+ # @param encryption_config [::Google::Cloud::Firestore::Admin::V1::Database::EncryptionConfig, ::Hash]
1991
+ # Optional. Encryption configuration for the restored database.
1992
+ #
1993
+ # If this field is not specified, the restored database will use
1994
+ # the same encryption configuration as the backup, namely
1995
+ # {::Google::Cloud::Firestore::Admin::V1::Database::EncryptionConfig#use_source_encryption use_source_encryption}.
1974
1996
  # @yield [result, operation] Access the result along with the TransportOperation object
1975
1997
  # @yieldparam result [::Gapic::Operation]
1976
1998
  # @yieldparam operation [::Gapic::Rest::TransportOperation]
@@ -2032,7 +2054,7 @@ module Google
2032
2054
  @firestore_admin_stub.restore_database request, options do |result, operation|
2033
2055
  result = ::Gapic::Operation.new result, @operations_client, options: options
2034
2056
  yield result, operation if block_given?
2035
- return result
2057
+ throw :response, result
2036
2058
  end
2037
2059
  rescue ::Gapic::Rest::Error => e
2038
2060
  raise ::Google::Cloud::Error.from_error(e)
@@ -2117,7 +2139,6 @@ module Google
2117
2139
 
2118
2140
  @firestore_admin_stub.create_backup_schedule request, options do |result, operation|
2119
2141
  yield result, operation if block_given?
2120
- return result
2121
2142
  end
2122
2143
  rescue ::Gapic::Rest::Error => e
2123
2144
  raise ::Google::Cloud::Error.from_error(e)
@@ -2199,7 +2220,6 @@ module Google
2199
2220
 
2200
2221
  @firestore_admin_stub.get_backup_schedule request, options do |result, operation|
2201
2222
  yield result, operation if block_given?
2202
- return result
2203
2223
  end
2204
2224
  rescue ::Gapic::Rest::Error => e
2205
2225
  raise ::Google::Cloud::Error.from_error(e)
@@ -2280,7 +2300,6 @@ module Google
2280
2300
 
2281
2301
  @firestore_admin_stub.list_backup_schedules request, options do |result, operation|
2282
2302
  yield result, operation if block_given?
2283
- return result
2284
2303
  end
2285
2304
  rescue ::Gapic::Rest::Error => e
2286
2305
  raise ::Google::Cloud::Error.from_error(e)
@@ -2361,7 +2380,6 @@ module Google
2361
2380
 
2362
2381
  @firestore_admin_stub.update_backup_schedule request, options do |result, operation|
2363
2382
  yield result, operation if block_given?
2364
- return result
2365
2383
  end
2366
2384
  rescue ::Gapic::Rest::Error => e
2367
2385
  raise ::Google::Cloud::Error.from_error(e)
@@ -2443,7 +2461,6 @@ module Google
2443
2461
 
2444
2462
  @firestore_admin_stub.delete_backup_schedule request, options do |result, operation|
2445
2463
  yield result, operation if block_given?
2446
- return result
2447
2464
  end
2448
2465
  rescue ::Gapic::Rest::Error => e
2449
2466
  raise ::Google::Cloud::Error.from_error(e)
@@ -2523,6 +2540,11 @@ module Google
2523
2540
  # default endpoint URL. The default value of nil uses the environment
2524
2541
  # universe (usually the default "googleapis.com" universe).
2525
2542
  # @return [::String,nil]
2543
+ # @!attribute [rw] logger
2544
+ # A custom logger to use for request/response debug logging, or the value
2545
+ # `:default` (the default) to construct a default logger, or `nil` to
2546
+ # explicitly disable logging.
2547
+ # @return [::Logger,:default,nil]
2526
2548
  #
2527
2549
  class Configuration
2528
2550
  extend ::Gapic::Config
@@ -2544,6 +2566,7 @@ module Google
2544
2566
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
2545
2567
  config_attr :quota_project, nil, ::String, nil
2546
2568
  config_attr :universe_domain, nil, ::String, nil
2569
+ config_attr :logger, :default, ::Logger, nil, :default
2547
2570
 
2548
2571
  # @private
2549
2572
  def initialize parent_config = nil
@@ -116,14 +116,6 @@ module Google
116
116
  # Lists operations that match the specified filter in the request. If the
117
117
  # server doesn't support this method, it returns `UNIMPLEMENTED`.
118
118
  #
119
- # NOTE: the `name` binding allows API services to override the binding
120
- # to use different resource name schemes, such as `users/*/operations`. To
121
- # override the binding, API services can add a binding such as
122
- # `"/v1/{name=users/*}/operations"` to their service configuration.
123
- # For backwards compatibility, the default name includes the operations
124
- # collection id, however overriding users must ensure the name binding
125
- # is the parent resource, without the operations collection id.
126
- #
127
119
  # @overload list_operations(request, options = nil)
128
120
  # Pass arguments to `list_operations` via a request object, either of type
129
121
  # {::Google::Longrunning::ListOperationsRequest} or an equivalent Hash.
@@ -205,7 +197,7 @@ module Google
205
197
  @operations_stub.list_operations request, options do |result, operation|
206
198
  result = ::Gapic::Rest::PagedEnumerable.new @operations_stub, :list_operations, "operations", request, result, options
207
199
  yield result, operation if block_given?
208
- return result
200
+ throw :response, result
209
201
  end
210
202
  rescue ::Gapic::Rest::Error => e
211
203
  raise ::Google::Cloud::Error.from_error(e)
@@ -294,7 +286,7 @@ module Google
294
286
  @operations_stub.get_operation request, options do |result, operation|
295
287
  result = ::Gapic::Operation.new result, @operations_client, options: options
296
288
  yield result, operation if block_given?
297
- return result
289
+ throw :response, result
298
290
  end
299
291
  rescue ::Gapic::Rest::Error => e
300
292
  raise ::Google::Cloud::Error.from_error(e)
@@ -376,7 +368,6 @@ module Google
376
368
 
377
369
  @operations_stub.delete_operation request, options do |result, operation|
378
370
  yield result, operation if block_given?
379
- return result
380
371
  end
381
372
  rescue ::Gapic::Rest::Error => e
382
373
  raise ::Google::Cloud::Error.from_error(e)
@@ -391,8 +382,9 @@ module Google
391
382
  # other methods to check whether the cancellation succeeded or whether the
392
383
  # operation completed despite cancellation. On successful cancellation,
393
384
  # the operation is not deleted; instead, it becomes an operation with
394
- # an {::Google::Longrunning::Operation#error Operation.error} value with a {::Google::Rpc::Status#code google.rpc.Status.code} of 1,
395
- # corresponding to `Code.CANCELLED`.
385
+ # an {::Google::Longrunning::Operation#error Operation.error} value with a
386
+ # {::Google::Rpc::Status#code google.rpc.Status.code} of `1`, corresponding to
387
+ # `Code.CANCELLED`.
396
388
  #
397
389
  # @overload cancel_operation(request, options = nil)
398
390
  # Pass arguments to `cancel_operation` via a request object, either of type
@@ -464,7 +456,6 @@ module Google
464
456
 
465
457
  @operations_stub.cancel_operation request, options do |result, operation|
466
458
  yield result, operation if block_given?
467
- return result
468
459
  end
469
460
  rescue ::Gapic::Rest::Error => e
470
461
  raise ::Google::Cloud::Error.from_error(e)
@@ -544,6 +535,11 @@ module Google
544
535
  # default endpoint URL. The default value of nil uses the environment
545
536
  # universe (usually the default "googleapis.com" universe).
546
537
  # @return [::String,nil]
538
+ # @!attribute [rw] logger
539
+ # A custom logger to use for request/response debug logging, or the value
540
+ # `:default` (the default) to construct a default logger, or `nil` to
541
+ # explicitly disable logging.
542
+ # @return [::Logger,:default,nil]
547
543
  #
548
544
  class Configuration
549
545
  extend ::Gapic::Config
@@ -565,6 +561,7 @@ module Google
565
561
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
566
562
  config_attr :quota_project, nil, ::String, nil
567
563
  config_attr :universe_domain, nil, ::String, nil
564
+ config_attr :logger, :default, ::Logger, nil, :default
568
565
 
569
566
  # @private
570
567
  def initialize parent_config = nil
@@ -684,16 +681,18 @@ module Google
684
681
 
685
682
  response = @client_stub.make_http_request(
686
683
  verb,
687
- uri: uri,
688
- body: body || "",
689
- params: query_string_params,
684
+ uri: uri,
685
+ body: body || "",
686
+ params: query_string_params,
687
+ method_name: "list_operations",
690
688
  options: options
691
689
  )
692
690
  operation = ::Gapic::Rest::TransportOperation.new response
693
691
  result = ::Google::Longrunning::ListOperationsResponse.decode_json response.body, ignore_unknown_fields: true
694
-
695
- yield result, operation if block_given?
696
- result
692
+ catch :response do
693
+ yield result, operation if block_given?
694
+ result
695
+ end
697
696
  end
698
697
 
699
698
  ##
@@ -722,16 +721,18 @@ module Google
722
721
 
723
722
  response = @client_stub.make_http_request(
724
723
  verb,
725
- uri: uri,
726
- body: body || "",
727
- params: query_string_params,
724
+ uri: uri,
725
+ body: body || "",
726
+ params: query_string_params,
727
+ method_name: "get_operation",
728
728
  options: options
729
729
  )
730
730
  operation = ::Gapic::Rest::TransportOperation.new response
731
731
  result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true
732
-
733
- yield result, operation if block_given?
734
- result
732
+ catch :response do
733
+ yield result, operation if block_given?
734
+ result
735
+ end
735
736
  end
736
737
 
737
738
  ##
@@ -760,16 +761,18 @@ module Google
760
761
 
761
762
  response = @client_stub.make_http_request(
762
763
  verb,
763
- uri: uri,
764
- body: body || "",
765
- params: query_string_params,
764
+ uri: uri,
765
+ body: body || "",
766
+ params: query_string_params,
767
+ method_name: "delete_operation",
766
768
  options: options
767
769
  )
768
770
  operation = ::Gapic::Rest::TransportOperation.new response
769
771
  result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
770
-
771
- yield result, operation if block_given?
772
- result
772
+ catch :response do
773
+ yield result, operation if block_given?
774
+ result
775
+ end
773
776
  end
774
777
 
775
778
  ##
@@ -798,16 +801,18 @@ module Google
798
801
 
799
802
  response = @client_stub.make_http_request(
800
803
  verb,
801
- uri: uri,
802
- body: body || "",
803
- params: query_string_params,
804
+ uri: uri,
805
+ body: body || "",
806
+ params: query_string_params,
807
+ method_name: "cancel_operation",
804
808
  options: options
805
809
  )
806
810
  operation = ::Gapic::Rest::TransportOperation.new response
807
811
  result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
808
-
809
- yield result, operation if block_given?
810
- result
812
+ catch :response do
813
+ yield result, operation if block_given?
814
+ result
815
+ end
811
816
  end
812
817
 
813
818
  ##