google-cloud-firestore-admin-v1 1.1.0 → 1.3.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.
@@ -136,6 +136,10 @@ module Google
136
136
 
137
137
  default_config.rpcs.bulk_delete_documents.timeout = 60.0
138
138
 
139
+ default_config.rpcs.create_database.timeout = 120.0
140
+
141
+ default_config.rpcs.restore_database.timeout = 120.0
142
+
139
143
  default_config
140
144
  end
141
145
  yield @configure if block_given?
@@ -221,14 +225,26 @@ module Google
221
225
  endpoint: @config.endpoint,
222
226
  endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
223
227
  universe_domain: @config.universe_domain,
224
- credentials: credentials
228
+ credentials: credentials,
229
+ logger: @config.logger
225
230
  )
226
231
 
232
+ @firestore_admin_stub.logger(stub: true)&.info do |entry|
233
+ entry.set_system_name
234
+ entry.set_service
235
+ entry.message = "Created client for #{entry.service}"
236
+ entry.set_credentials_fields credentials
237
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
238
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
239
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
240
+ end
241
+
227
242
  @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
228
243
  config.credentials = credentials
229
244
  config.quota_project = @quota_project_id
230
245
  config.endpoint = @firestore_admin_stub.endpoint
231
246
  config.universe_domain = @firestore_admin_stub.universe_domain
247
+ config.logger = @firestore_admin_stub.logger if config.respond_to? :logger=
232
248
  end
233
249
  end
234
250
 
@@ -246,6 +262,15 @@ module Google
246
262
  #
247
263
  attr_reader :location_client
248
264
 
265
+ ##
266
+ # The logger used for request/response debug logging.
267
+ #
268
+ # @return [Logger]
269
+ #
270
+ def logger
271
+ @firestore_admin_stub.logger
272
+ end
273
+
249
274
  # Service calls
250
275
 
251
276
  ##
@@ -336,7 +361,7 @@ module Google
336
361
  @firestore_admin_stub.create_index request, options do |result, operation|
337
362
  result = ::Gapic::Operation.new result, @operations_client, options: options
338
363
  yield result, operation if block_given?
339
- return result
364
+ throw :response, result
340
365
  end
341
366
  rescue ::Gapic::Rest::Error => e
342
367
  raise ::Google::Cloud::Error.from_error(e)
@@ -429,7 +454,7 @@ module Google
429
454
  @firestore_admin_stub.list_indexes request, options do |result, operation|
430
455
  result = ::Gapic::Rest::PagedEnumerable.new @firestore_admin_stub, :list_indexes, "indexes", request, result, options
431
456
  yield result, operation if block_given?
432
- return result
457
+ throw :response, result
433
458
  end
434
459
  rescue ::Gapic::Rest::Error => e
435
460
  raise ::Google::Cloud::Error.from_error(e)
@@ -509,7 +534,6 @@ module Google
509
534
 
510
535
  @firestore_admin_stub.get_index request, options do |result, operation|
511
536
  yield result, operation if block_given?
512
- return result
513
537
  end
514
538
  rescue ::Gapic::Rest::Error => e
515
539
  raise ::Google::Cloud::Error.from_error(e)
@@ -589,7 +613,6 @@ module Google
589
613
 
590
614
  @firestore_admin_stub.delete_index request, options do |result, operation|
591
615
  yield result, operation if block_given?
592
- return result
593
616
  end
594
617
  rescue ::Gapic::Rest::Error => e
595
618
  raise ::Google::Cloud::Error.from_error(e)
@@ -669,7 +692,6 @@ module Google
669
692
 
670
693
  @firestore_admin_stub.get_field request, options do |result, operation|
671
694
  yield result, operation if block_given?
672
- return result
673
695
  end
674
696
  rescue ::Gapic::Rest::Error => e
675
697
  raise ::Google::Cloud::Error.from_error(e)
@@ -774,7 +796,7 @@ module Google
774
796
  @firestore_admin_stub.update_field request, options do |result, operation|
775
797
  result = ::Gapic::Operation.new result, @operations_client, options: options
776
798
  yield result, operation if block_given?
777
- return result
799
+ throw :response, result
778
800
  end
779
801
  rescue ::Gapic::Rest::Error => e
780
802
  raise ::Google::Cloud::Error.from_error(e)
@@ -881,7 +903,7 @@ module Google
881
903
  @firestore_admin_stub.list_fields request, options do |result, operation|
882
904
  result = ::Gapic::Rest::PagedEnumerable.new @firestore_admin_stub, :list_fields, "fields", request, result, options
883
905
  yield result, operation if block_given?
884
- return result
906
+ throw :response, result
885
907
  end
886
908
  rescue ::Gapic::Rest::Error => e
887
909
  raise ::Google::Cloud::Error.from_error(e)
@@ -1006,7 +1028,7 @@ module Google
1006
1028
  @firestore_admin_stub.export_documents request, options do |result, operation|
1007
1029
  result = ::Gapic::Operation.new result, @operations_client, options: options
1008
1030
  yield result, operation if block_given?
1009
- return result
1031
+ throw :response, result
1010
1032
  end
1011
1033
  rescue ::Gapic::Rest::Error => e
1012
1034
  raise ::Google::Cloud::Error.from_error(e)
@@ -1114,7 +1136,7 @@ module Google
1114
1136
  @firestore_admin_stub.import_documents request, options do |result, operation|
1115
1137
  result = ::Gapic::Operation.new result, @operations_client, options: options
1116
1138
  yield result, operation if block_given?
1117
- return result
1139
+ throw :response, result
1118
1140
  end
1119
1141
  rescue ::Gapic::Rest::Error => e
1120
1142
  raise ::Google::Cloud::Error.from_error(e)
@@ -1225,7 +1247,7 @@ module Google
1225
1247
  @firestore_admin_stub.bulk_delete_documents request, options do |result, operation|
1226
1248
  result = ::Gapic::Operation.new result, @operations_client, options: options
1227
1249
  yield result, operation if block_given?
1228
- return result
1250
+ throw :response, result
1229
1251
  end
1230
1252
  rescue ::Gapic::Rest::Error => e
1231
1253
  raise ::Google::Cloud::Error.from_error(e)
@@ -1324,7 +1346,7 @@ module Google
1324
1346
  @firestore_admin_stub.create_database request, options do |result, operation|
1325
1347
  result = ::Gapic::Operation.new result, @operations_client, options: options
1326
1348
  yield result, operation if block_given?
1327
- return result
1349
+ throw :response, result
1328
1350
  end
1329
1351
  rescue ::Gapic::Rest::Error => e
1330
1352
  raise ::Google::Cloud::Error.from_error(e)
@@ -1404,7 +1426,6 @@ module Google
1404
1426
 
1405
1427
  @firestore_admin_stub.get_database request, options do |result, operation|
1406
1428
  yield result, operation if block_given?
1407
- return result
1408
1429
  end
1409
1430
  rescue ::Gapic::Rest::Error => e
1410
1431
  raise ::Google::Cloud::Error.from_error(e)
@@ -1486,7 +1507,6 @@ module Google
1486
1507
 
1487
1508
  @firestore_admin_stub.list_databases request, options do |result, operation|
1488
1509
  yield result, operation if block_given?
1489
- return result
1490
1510
  end
1491
1511
  rescue ::Gapic::Rest::Error => e
1492
1512
  raise ::Google::Cloud::Error.from_error(e)
@@ -1575,7 +1595,7 @@ module Google
1575
1595
  @firestore_admin_stub.update_database request, options do |result, operation|
1576
1596
  result = ::Gapic::Operation.new result, @operations_client, options: options
1577
1597
  yield result, operation if block_given?
1578
- return result
1598
+ throw :response, result
1579
1599
  end
1580
1600
  rescue ::Gapic::Rest::Error => e
1581
1601
  raise ::Google::Cloud::Error.from_error(e)
@@ -1667,7 +1687,7 @@ module Google
1667
1687
  @firestore_admin_stub.delete_database request, options do |result, operation|
1668
1688
  result = ::Gapic::Operation.new result, @operations_client, options: options
1669
1689
  yield result, operation if block_given?
1670
- return result
1690
+ throw :response, result
1671
1691
  end
1672
1692
  rescue ::Gapic::Rest::Error => e
1673
1693
  raise ::Google::Cloud::Error.from_error(e)
@@ -1748,7 +1768,6 @@ module Google
1748
1768
 
1749
1769
  @firestore_admin_stub.get_backup request, options do |result, operation|
1750
1770
  yield result, operation if block_given?
1751
- return result
1752
1771
  end
1753
1772
  rescue ::Gapic::Rest::Error => e
1754
1773
  raise ::Google::Cloud::Error.from_error(e)
@@ -1767,7 +1786,7 @@ module Google
1767
1786
  # @param options [::Gapic::CallOptions, ::Hash]
1768
1787
  # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1769
1788
  #
1770
- # @overload list_backups(parent: nil)
1789
+ # @overload list_backups(parent: nil, filter: nil)
1771
1790
  # Pass arguments to `list_backups` via keyword arguments. Note that at
1772
1791
  # least one keyword argument is required. To specify no parameters, or to keep all
1773
1792
  # the default parameter values, pass an empty Hash as a request object (see above).
@@ -1779,6 +1798,19 @@ module Google
1779
1798
  # Use `{location} = '-'` to list backups from all locations for the given
1780
1799
  # project. This allows listing backups from a single location or from all
1781
1800
  # locations.
1801
+ # @param filter [::String]
1802
+ # An expression that filters the list of returned backups.
1803
+ #
1804
+ # A filter expression consists of a field name, a comparison operator, and a
1805
+ # value for filtering.
1806
+ # The value must be a string, a number, or a boolean. The comparison operator
1807
+ # must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`.
1808
+ # Colon `:` is the contains operator. Filter rules are not case sensitive.
1809
+ #
1810
+ # The following fields in the {::Google::Cloud::Firestore::Admin::V1::Backup Backup} are
1811
+ # eligible for filtering:
1812
+ #
1813
+ # * `database_uid` (supports `=` only)
1782
1814
  # @yield [result, operation] Access the result along with the TransportOperation object
1783
1815
  # @yieldparam result [::Google::Cloud::Firestore::Admin::V1::ListBackupsResponse]
1784
1816
  # @yieldparam operation [::Gapic::Rest::TransportOperation]
@@ -1832,7 +1864,6 @@ module Google
1832
1864
 
1833
1865
  @firestore_admin_stub.list_backups request, options do |result, operation|
1834
1866
  yield result, operation if block_given?
1835
- return result
1836
1867
  end
1837
1868
  rescue ::Gapic::Rest::Error => e
1838
1869
  raise ::Google::Cloud::Error.from_error(e)
@@ -1913,7 +1944,6 @@ module Google
1913
1944
 
1914
1945
  @firestore_admin_stub.delete_backup request, options do |result, operation|
1915
1946
  yield result, operation if block_given?
1916
- return result
1917
1947
  end
1918
1948
  rescue ::Gapic::Rest::Error => e
1919
1949
  raise ::Google::Cloud::Error.from_error(e)
@@ -2041,7 +2071,7 @@ module Google
2041
2071
  @firestore_admin_stub.restore_database request, options do |result, operation|
2042
2072
  result = ::Gapic::Operation.new result, @operations_client, options: options
2043
2073
  yield result, operation if block_given?
2044
- return result
2074
+ throw :response, result
2045
2075
  end
2046
2076
  rescue ::Gapic::Rest::Error => e
2047
2077
  raise ::Google::Cloud::Error.from_error(e)
@@ -2126,7 +2156,6 @@ module Google
2126
2156
 
2127
2157
  @firestore_admin_stub.create_backup_schedule request, options do |result, operation|
2128
2158
  yield result, operation if block_given?
2129
- return result
2130
2159
  end
2131
2160
  rescue ::Gapic::Rest::Error => e
2132
2161
  raise ::Google::Cloud::Error.from_error(e)
@@ -2208,7 +2237,6 @@ module Google
2208
2237
 
2209
2238
  @firestore_admin_stub.get_backup_schedule request, options do |result, operation|
2210
2239
  yield result, operation if block_given?
2211
- return result
2212
2240
  end
2213
2241
  rescue ::Gapic::Rest::Error => e
2214
2242
  raise ::Google::Cloud::Error.from_error(e)
@@ -2289,7 +2317,6 @@ module Google
2289
2317
 
2290
2318
  @firestore_admin_stub.list_backup_schedules request, options do |result, operation|
2291
2319
  yield result, operation if block_given?
2292
- return result
2293
2320
  end
2294
2321
  rescue ::Gapic::Rest::Error => e
2295
2322
  raise ::Google::Cloud::Error.from_error(e)
@@ -2370,7 +2397,6 @@ module Google
2370
2397
 
2371
2398
  @firestore_admin_stub.update_backup_schedule request, options do |result, operation|
2372
2399
  yield result, operation if block_given?
2373
- return result
2374
2400
  end
2375
2401
  rescue ::Gapic::Rest::Error => e
2376
2402
  raise ::Google::Cloud::Error.from_error(e)
@@ -2452,7 +2478,6 @@ module Google
2452
2478
 
2453
2479
  @firestore_admin_stub.delete_backup_schedule request, options do |result, operation|
2454
2480
  yield result, operation if block_given?
2455
- return result
2456
2481
  end
2457
2482
  rescue ::Gapic::Rest::Error => e
2458
2483
  raise ::Google::Cloud::Error.from_error(e)
@@ -2500,6 +2525,13 @@ module Google
2500
2525
  # * (`Signet::OAuth2::Client`) A signet oauth2 client object
2501
2526
  # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
2502
2527
  # * (`nil`) indicating no credentials
2528
+ #
2529
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
2530
+ # external source for authentication to Google Cloud, you must validate it before
2531
+ # providing it to a Google API client library. Providing an unvalidated credential
2532
+ # configuration to Google APIs can compromise the security of your systems and data.
2533
+ # For more information, refer to [Validate credential configurations from external
2534
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
2503
2535
  # @return [::Object]
2504
2536
  # @!attribute [rw] scope
2505
2537
  # The OAuth scopes
@@ -2532,6 +2564,11 @@ module Google
2532
2564
  # default endpoint URL. The default value of nil uses the environment
2533
2565
  # universe (usually the default "googleapis.com" universe).
2534
2566
  # @return [::String,nil]
2567
+ # @!attribute [rw] logger
2568
+ # A custom logger to use for request/response debug logging, or the value
2569
+ # `:default` (the default) to construct a default logger, or `nil` to
2570
+ # explicitly disable logging.
2571
+ # @return [::Logger,:default,nil]
2535
2572
  #
2536
2573
  class Configuration
2537
2574
  extend ::Gapic::Config
@@ -2553,6 +2590,7 @@ module Google
2553
2590
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
2554
2591
  config_attr :quota_project, nil, ::String, nil
2555
2592
  config_attr :universe_domain, nil, ::String, nil
2593
+ config_attr :logger, :default, ::Logger, nil, :default
2556
2594
 
2557
2595
  # @private
2558
2596
  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)
@@ -512,6 +503,13 @@ module Google
512
503
  # * (`Signet::OAuth2::Client`) A signet oauth2 client object
513
504
  # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
514
505
  # * (`nil`) indicating no credentials
506
+ #
507
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
508
+ # external source for authentication to Google Cloud, you must validate it before
509
+ # providing it to a Google API client library. Providing an unvalidated credential
510
+ # configuration to Google APIs can compromise the security of your systems and data.
511
+ # For more information, refer to [Validate credential configurations from external
512
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
515
513
  # @return [::Object]
516
514
  # @!attribute [rw] scope
517
515
  # The OAuth scopes
@@ -544,6 +542,11 @@ module Google
544
542
  # default endpoint URL. The default value of nil uses the environment
545
543
  # universe (usually the default "googleapis.com" universe).
546
544
  # @return [::String,nil]
545
+ # @!attribute [rw] logger
546
+ # A custom logger to use for request/response debug logging, or the value
547
+ # `:default` (the default) to construct a default logger, or `nil` to
548
+ # explicitly disable logging.
549
+ # @return [::Logger,:default,nil]
547
550
  #
548
551
  class Configuration
549
552
  extend ::Gapic::Config
@@ -565,6 +568,7 @@ module Google
565
568
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
566
569
  config_attr :quota_project, nil, ::String, nil
567
570
  config_attr :universe_domain, nil, ::String, nil
571
+ config_attr :logger, :default, ::Logger, nil, :default
568
572
 
569
573
  # @private
570
574
  def initialize parent_config = nil
@@ -684,16 +688,18 @@ module Google
684
688
 
685
689
  response = @client_stub.make_http_request(
686
690
  verb,
687
- uri: uri,
688
- body: body || "",
689
- params: query_string_params,
691
+ uri: uri,
692
+ body: body || "",
693
+ params: query_string_params,
694
+ method_name: "list_operations",
690
695
  options: options
691
696
  )
692
697
  operation = ::Gapic::Rest::TransportOperation.new response
693
698
  result = ::Google::Longrunning::ListOperationsResponse.decode_json response.body, ignore_unknown_fields: true
694
-
695
- yield result, operation if block_given?
696
- result
699
+ catch :response do
700
+ yield result, operation if block_given?
701
+ result
702
+ end
697
703
  end
698
704
 
699
705
  ##
@@ -722,16 +728,18 @@ module Google
722
728
 
723
729
  response = @client_stub.make_http_request(
724
730
  verb,
725
- uri: uri,
726
- body: body || "",
727
- params: query_string_params,
731
+ uri: uri,
732
+ body: body || "",
733
+ params: query_string_params,
734
+ method_name: "get_operation",
728
735
  options: options
729
736
  )
730
737
  operation = ::Gapic::Rest::TransportOperation.new response
731
738
  result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true
732
-
733
- yield result, operation if block_given?
734
- result
739
+ catch :response do
740
+ yield result, operation if block_given?
741
+ result
742
+ end
735
743
  end
736
744
 
737
745
  ##
@@ -760,16 +768,18 @@ module Google
760
768
 
761
769
  response = @client_stub.make_http_request(
762
770
  verb,
763
- uri: uri,
764
- body: body || "",
765
- params: query_string_params,
771
+ uri: uri,
772
+ body: body || "",
773
+ params: query_string_params,
774
+ method_name: "delete_operation",
766
775
  options: options
767
776
  )
768
777
  operation = ::Gapic::Rest::TransportOperation.new response
769
778
  result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
770
-
771
- yield result, operation if block_given?
772
- result
779
+ catch :response do
780
+ yield result, operation if block_given?
781
+ result
782
+ end
773
783
  end
774
784
 
775
785
  ##
@@ -798,16 +808,18 @@ module Google
798
808
 
799
809
  response = @client_stub.make_http_request(
800
810
  verb,
801
- uri: uri,
802
- body: body || "",
803
- params: query_string_params,
811
+ uri: uri,
812
+ body: body || "",
813
+ params: query_string_params,
814
+ method_name: "cancel_operation",
804
815
  options: options
805
816
  )
806
817
  operation = ::Gapic::Rest::TransportOperation.new response
807
818
  result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
808
-
809
- yield result, operation if block_given?
810
- result
819
+ catch :response do
820
+ yield result, operation if block_given?
821
+ result
822
+ end
811
823
  end
812
824
 
813
825
  ##