google-cloud-firestore-admin-v1 1.1.0 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ffaad199ed27b9bb693aef19697ac7c8efe7cbbcbb78dfe558f664c173edb99e
4
- data.tar.gz: 617aff9e02031a7eda441586220edb5e9cbc6e24f6400017b6eac5d7a1f3da11
3
+ metadata.gz: 59f3bce4b8eba2e0a9cabd07d4a3712392f53a20ec8a6f145ef992dbbba7c1b0
4
+ data.tar.gz: 3377348ae0e89c1c212031e1e0a8e3802abf60a9fda737a047cd2d5c53cd09db
5
5
  SHA512:
6
- metadata.gz: 3cf0b6cf8c9190f614f3eae1dfffa1fd1047fa0f88bb144e9aeeef4094574a9b18d85c3ca352bafd13e993e10d4a825671bab70059d5a005f6350f89dade3668
7
- data.tar.gz: e2864ba70b134189f51f16b7dc218ef1e65a76a95c5024faeb9207372b5e4603fd04416588b556a6e1c3f103e47215375b5c0b8eb2d4c8140fe68db2b18d81e2
6
+ metadata.gz: 5af37de864037b72cdf167032242a57675b84121dbc8a092457e179b75d7b0cc17269af1df1e09a45cea3418b840fabe275c0ebd430d3dba8e1367de9b27403f
7
+ data.tar.gz: b12492ff42aec8d32707d498fa69700dd0b1614a5bdab9d114f3a8e4f3703c28208965da831df0299f4a0b102852ce8e204de833f0ab409a6eaad57083828f21
data/README.md CHANGED
@@ -43,33 +43,43 @@ for class and method documentation.
43
43
  See also the [Product Documentation](https://cloud.google.com/firestore)
44
44
  for general usage information.
45
45
 
46
- ## Enabling Logging
47
-
48
- To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
49
- The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/current/stdlibs/logger/Logger.html) as shown below,
50
- or a [`Google::Cloud::Logging::Logger`](https://cloud.google.com/ruby/docs/reference/google-cloud-logging/latest)
51
- that will write logs to [Cloud Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
52
- and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
53
-
54
- Configuring a Ruby stdlib logger:
46
+ ## Debug Logging
47
+
48
+ This library comes with opt-in Debug Logging that can help you troubleshoot
49
+ your application's integration with the API. When logging is activated, key
50
+ events such as requests and responses, along with data payloads and metadata
51
+ such as headers and client configuration, are logged to the standard error
52
+ stream.
53
+
54
+ **WARNING:** Client Library Debug Logging includes your data payloads in
55
+ plaintext, which could include sensitive data such as PII for yourself or your
56
+ customers, private keys, or other security data that could be compromising if
57
+ leaked. Always practice good data hygiene with your application logs, and follow
58
+ the principle of least access. Google also recommends that Client Library Debug
59
+ Logging be enabled only temporarily during active debugging, and not used
60
+ permanently in production.
61
+
62
+ To enable logging, set the environment variable `GOOGLE_SDK_RUBY_LOGGING_GEMS`
63
+ to the value `all`. Alternatively, you can set the value to a comma-delimited
64
+ list of client library gem names. This will select the default logging behavior,
65
+ which writes logs to the standard error stream. On a local workstation, this may
66
+ result in logs appearing on the console. When running on a Google Cloud hosting
67
+ service such as [Google Cloud Run](https://cloud.google.com/run), this generally
68
+ results in logs appearing alongside your application logs in the
69
+ [Google Cloud Logging](https://cloud.google.com/logging/) service.
70
+
71
+ You can customize logging by modifying the `logger` configuration when
72
+ constructing a client object. For example:
55
73
 
56
74
  ```ruby
75
+ require "google/cloud/firestore/admin/v1"
57
76
  require "logger"
58
77
 
59
- module MyLogger
60
- LOGGER = Logger.new $stderr, level: Logger::WARN
61
- def logger
62
- LOGGER
63
- end
64
- end
65
-
66
- # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
67
- module GRPC
68
- extend MyLogger
78
+ client = ::Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client.new do |config|
79
+ config.logger = Logger.new "my-app.log"
69
80
  end
70
81
  ```
71
82
 
72
-
73
83
  ## Google Cloud Samples
74
84
 
75
85
  To browse ready to use code samples check [Google Cloud Samples](https://cloud.google.com/docs/samples).
@@ -228,14 +228,26 @@ module Google
228
228
  universe_domain: @config.universe_domain,
229
229
  channel_args: @config.channel_args,
230
230
  interceptors: @config.interceptors,
231
- channel_pool_config: @config.channel_pool
231
+ channel_pool_config: @config.channel_pool,
232
+ logger: @config.logger
232
233
  )
233
234
 
235
+ @firestore_admin_stub.stub_logger&.info do |entry|
236
+ entry.set_system_name
237
+ entry.set_service
238
+ entry.message = "Created client for #{entry.service}"
239
+ entry.set_credentials_fields credentials
240
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
241
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
242
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
243
+ end
244
+
234
245
  @location_client = Google::Cloud::Location::Locations::Client.new do |config|
235
246
  config.credentials = credentials
236
247
  config.quota_project = @quota_project_id
237
248
  config.endpoint = @firestore_admin_stub.endpoint
238
249
  config.universe_domain = @firestore_admin_stub.universe_domain
250
+ config.logger = @firestore_admin_stub.logger if config.respond_to? :logger=
239
251
  end
240
252
  end
241
253
 
@@ -253,6 +265,15 @@ module Google
253
265
  #
254
266
  attr_reader :location_client
255
267
 
268
+ ##
269
+ # The logger used for request/response debug logging.
270
+ #
271
+ # @return [Logger]
272
+ #
273
+ def logger
274
+ @firestore_admin_stub.logger
275
+ end
276
+
256
277
  # Service calls
257
278
 
258
279
  ##
@@ -350,7 +371,7 @@ module Google
350
371
  @firestore_admin_stub.call_rpc :create_index, request, options: options do |response, operation|
351
372
  response = ::Gapic::Operation.new response, @operations_client, options: options
352
373
  yield response, operation if block_given?
353
- return response
374
+ throw :response, response
354
375
  end
355
376
  rescue ::GRPC::BadStatus => e
356
377
  raise ::Google::Cloud::Error.from_error(e)
@@ -450,7 +471,7 @@ module Google
450
471
  @firestore_admin_stub.call_rpc :list_indexes, request, options: options do |response, operation|
451
472
  response = ::Gapic::PagedEnumerable.new @firestore_admin_stub, :list_indexes, request, response, operation, options
452
473
  yield response, operation if block_given?
453
- return response
474
+ throw :response, response
454
475
  end
455
476
  rescue ::GRPC::BadStatus => e
456
477
  raise ::Google::Cloud::Error.from_error(e)
@@ -537,7 +558,6 @@ module Google
537
558
 
538
559
  @firestore_admin_stub.call_rpc :get_index, request, options: options do |response, operation|
539
560
  yield response, operation if block_given?
540
- return response
541
561
  end
542
562
  rescue ::GRPC::BadStatus => e
543
563
  raise ::Google::Cloud::Error.from_error(e)
@@ -624,7 +644,6 @@ module Google
624
644
 
625
645
  @firestore_admin_stub.call_rpc :delete_index, request, options: options do |response, operation|
626
646
  yield response, operation if block_given?
627
- return response
628
647
  end
629
648
  rescue ::GRPC::BadStatus => e
630
649
  raise ::Google::Cloud::Error.from_error(e)
@@ -711,7 +730,6 @@ module Google
711
730
 
712
731
  @firestore_admin_stub.call_rpc :get_field, request, options: options do |response, operation|
713
732
  yield response, operation if block_given?
714
- return response
715
733
  end
716
734
  rescue ::GRPC::BadStatus => e
717
735
  raise ::Google::Cloud::Error.from_error(e)
@@ -823,7 +841,7 @@ module Google
823
841
  @firestore_admin_stub.call_rpc :update_field, request, options: options do |response, operation|
824
842
  response = ::Gapic::Operation.new response, @operations_client, options: options
825
843
  yield response, operation if block_given?
826
- return response
844
+ throw :response, response
827
845
  end
828
846
  rescue ::GRPC::BadStatus => e
829
847
  raise ::Google::Cloud::Error.from_error(e)
@@ -937,7 +955,7 @@ module Google
937
955
  @firestore_admin_stub.call_rpc :list_fields, request, options: options do |response, operation|
938
956
  response = ::Gapic::PagedEnumerable.new @firestore_admin_stub, :list_fields, request, response, operation, options
939
957
  yield response, operation if block_given?
940
- return response
958
+ throw :response, response
941
959
  end
942
960
  rescue ::GRPC::BadStatus => e
943
961
  raise ::Google::Cloud::Error.from_error(e)
@@ -1069,7 +1087,7 @@ module Google
1069
1087
  @firestore_admin_stub.call_rpc :export_documents, request, options: options do |response, operation|
1070
1088
  response = ::Gapic::Operation.new response, @operations_client, options: options
1071
1089
  yield response, operation if block_given?
1072
- return response
1090
+ throw :response, response
1073
1091
  end
1074
1092
  rescue ::GRPC::BadStatus => e
1075
1093
  raise ::Google::Cloud::Error.from_error(e)
@@ -1184,7 +1202,7 @@ module Google
1184
1202
  @firestore_admin_stub.call_rpc :import_documents, request, options: options do |response, operation|
1185
1203
  response = ::Gapic::Operation.new response, @operations_client, options: options
1186
1204
  yield response, operation if block_given?
1187
- return response
1205
+ throw :response, response
1188
1206
  end
1189
1207
  rescue ::GRPC::BadStatus => e
1190
1208
  raise ::Google::Cloud::Error.from_error(e)
@@ -1302,7 +1320,7 @@ module Google
1302
1320
  @firestore_admin_stub.call_rpc :bulk_delete_documents, request, options: options do |response, operation|
1303
1321
  response = ::Gapic::Operation.new response, @operations_client, options: options
1304
1322
  yield response, operation if block_given?
1305
- return response
1323
+ throw :response, response
1306
1324
  end
1307
1325
  rescue ::GRPC::BadStatus => e
1308
1326
  raise ::Google::Cloud::Error.from_error(e)
@@ -1408,7 +1426,7 @@ module Google
1408
1426
  @firestore_admin_stub.call_rpc :create_database, request, options: options do |response, operation|
1409
1427
  response = ::Gapic::Operation.new response, @operations_client, options: options
1410
1428
  yield response, operation if block_given?
1411
- return response
1429
+ throw :response, response
1412
1430
  end
1413
1431
  rescue ::GRPC::BadStatus => e
1414
1432
  raise ::Google::Cloud::Error.from_error(e)
@@ -1495,7 +1513,6 @@ module Google
1495
1513
 
1496
1514
  @firestore_admin_stub.call_rpc :get_database, request, options: options do |response, operation|
1497
1515
  yield response, operation if block_given?
1498
- return response
1499
1516
  end
1500
1517
  rescue ::GRPC::BadStatus => e
1501
1518
  raise ::Google::Cloud::Error.from_error(e)
@@ -1584,7 +1601,6 @@ module Google
1584
1601
 
1585
1602
  @firestore_admin_stub.call_rpc :list_databases, request, options: options do |response, operation|
1586
1603
  yield response, operation if block_given?
1587
- return response
1588
1604
  end
1589
1605
  rescue ::GRPC::BadStatus => e
1590
1606
  raise ::Google::Cloud::Error.from_error(e)
@@ -1680,7 +1696,7 @@ module Google
1680
1696
  @firestore_admin_stub.call_rpc :update_database, request, options: options do |response, operation|
1681
1697
  response = ::Gapic::Operation.new response, @operations_client, options: options
1682
1698
  yield response, operation if block_given?
1683
- return response
1699
+ throw :response, response
1684
1700
  end
1685
1701
  rescue ::GRPC::BadStatus => e
1686
1702
  raise ::Google::Cloud::Error.from_error(e)
@@ -1779,7 +1795,7 @@ module Google
1779
1795
  @firestore_admin_stub.call_rpc :delete_database, request, options: options do |response, operation|
1780
1796
  response = ::Gapic::Operation.new response, @operations_client, options: options
1781
1797
  yield response, operation if block_given?
1782
- return response
1798
+ throw :response, response
1783
1799
  end
1784
1800
  rescue ::GRPC::BadStatus => e
1785
1801
  raise ::Google::Cloud::Error.from_error(e)
@@ -1867,7 +1883,6 @@ module Google
1867
1883
 
1868
1884
  @firestore_admin_stub.call_rpc :get_backup, request, options: options do |response, operation|
1869
1885
  yield response, operation if block_given?
1870
- return response
1871
1886
  end
1872
1887
  rescue ::GRPC::BadStatus => e
1873
1888
  raise ::Google::Cloud::Error.from_error(e)
@@ -1958,7 +1973,6 @@ module Google
1958
1973
 
1959
1974
  @firestore_admin_stub.call_rpc :list_backups, request, options: options do |response, operation|
1960
1975
  yield response, operation if block_given?
1961
- return response
1962
1976
  end
1963
1977
  rescue ::GRPC::BadStatus => e
1964
1978
  raise ::Google::Cloud::Error.from_error(e)
@@ -2046,7 +2060,6 @@ module Google
2046
2060
 
2047
2061
  @firestore_admin_stub.call_rpc :delete_backup, request, options: options do |response, operation|
2048
2062
  yield response, operation if block_given?
2049
- return response
2050
2063
  end
2051
2064
  rescue ::GRPC::BadStatus => e
2052
2065
  raise ::Google::Cloud::Error.from_error(e)
@@ -2181,7 +2194,7 @@ module Google
2181
2194
  @firestore_admin_stub.call_rpc :restore_database, request, options: options do |response, operation|
2182
2195
  response = ::Gapic::Operation.new response, @operations_client, options: options
2183
2196
  yield response, operation if block_given?
2184
- return response
2197
+ throw :response, response
2185
2198
  end
2186
2199
  rescue ::GRPC::BadStatus => e
2187
2200
  raise ::Google::Cloud::Error.from_error(e)
@@ -2273,7 +2286,6 @@ module Google
2273
2286
 
2274
2287
  @firestore_admin_stub.call_rpc :create_backup_schedule, request, options: options do |response, operation|
2275
2288
  yield response, operation if block_given?
2276
- return response
2277
2289
  end
2278
2290
  rescue ::GRPC::BadStatus => e
2279
2291
  raise ::Google::Cloud::Error.from_error(e)
@@ -2362,7 +2374,6 @@ module Google
2362
2374
 
2363
2375
  @firestore_admin_stub.call_rpc :get_backup_schedule, request, options: options do |response, operation|
2364
2376
  yield response, operation if block_given?
2365
- return response
2366
2377
  end
2367
2378
  rescue ::GRPC::BadStatus => e
2368
2379
  raise ::Google::Cloud::Error.from_error(e)
@@ -2450,7 +2461,6 @@ module Google
2450
2461
 
2451
2462
  @firestore_admin_stub.call_rpc :list_backup_schedules, request, options: options do |response, operation|
2452
2463
  yield response, operation if block_given?
2453
- return response
2454
2464
  end
2455
2465
  rescue ::GRPC::BadStatus => e
2456
2466
  raise ::Google::Cloud::Error.from_error(e)
@@ -2538,7 +2548,6 @@ module Google
2538
2548
 
2539
2549
  @firestore_admin_stub.call_rpc :update_backup_schedule, request, options: options do |response, operation|
2540
2550
  yield response, operation if block_given?
2541
- return response
2542
2551
  end
2543
2552
  rescue ::GRPC::BadStatus => e
2544
2553
  raise ::Google::Cloud::Error.from_error(e)
@@ -2627,7 +2636,6 @@ module Google
2627
2636
 
2628
2637
  @firestore_admin_stub.call_rpc :delete_backup_schedule, request, options: options do |response, operation|
2629
2638
  yield response, operation if block_given?
2630
- return response
2631
2639
  end
2632
2640
  rescue ::GRPC::BadStatus => e
2633
2641
  raise ::Google::Cloud::Error.from_error(e)
@@ -2716,6 +2724,11 @@ module Google
2716
2724
  # default endpoint URL. The default value of nil uses the environment
2717
2725
  # universe (usually the default "googleapis.com" universe).
2718
2726
  # @return [::String,nil]
2727
+ # @!attribute [rw] logger
2728
+ # A custom logger to use for request/response debug logging, or the value
2729
+ # `:default` (the default) to construct a default logger, or `nil` to
2730
+ # explicitly disable logging.
2731
+ # @return [::Logger,:default,nil]
2719
2732
  #
2720
2733
  class Configuration
2721
2734
  extend ::Gapic::Config
@@ -2740,6 +2753,7 @@ module Google
2740
2753
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
2741
2754
  config_attr :quota_project, nil, ::String, nil
2742
2755
  config_attr :universe_domain, nil, ::String, nil
2756
+ config_attr :logger, :default, ::Logger, nil, :default
2743
2757
 
2744
2758
  # @private
2745
2759
  def initialize parent_config = nil
@@ -125,14 +125,6 @@ module Google
125
125
  # Lists operations that match the specified filter in the request. If the
126
126
  # server doesn't support this method, it returns `UNIMPLEMENTED`.
127
127
  #
128
- # NOTE: the `name` binding allows API services to override the binding
129
- # to use different resource name schemes, such as `users/*/operations`. To
130
- # override the binding, API services can add a binding such as
131
- # `"/v1/{name=users/*}/operations"` to their service configuration.
132
- # For backwards compatibility, the default name includes the operations
133
- # collection id, however overriding users must ensure the name binding
134
- # is the parent resource, without the operations collection id.
135
- #
136
128
  # @overload list_operations(request, options = nil)
137
129
  # Pass arguments to `list_operations` via a request object, either of type
138
130
  # {::Google::Longrunning::ListOperationsRequest} or an equivalent Hash.
@@ -222,7 +214,7 @@ module Google
222
214
  wrap_lro_operation = ->(op_response) { ::Gapic::Operation.new op_response, @operations_client }
223
215
  response = ::Gapic::PagedEnumerable.new @operations_stub, :list_operations, request, response, operation, options, format_resource: wrap_lro_operation
224
216
  yield response, operation if block_given?
225
- return response
217
+ throw :response, response
226
218
  end
227
219
  rescue ::GRPC::BadStatus => e
228
220
  raise ::Google::Cloud::Error.from_error(e)
@@ -318,7 +310,7 @@ module Google
318
310
  @operations_stub.call_rpc :get_operation, request, options: options do |response, operation|
319
311
  response = ::Gapic::Operation.new response, @operations_client, options: options
320
312
  yield response, operation if block_given?
321
- return response
313
+ throw :response, response
322
314
  end
323
315
  rescue ::GRPC::BadStatus => e
324
316
  raise ::Google::Cloud::Error.from_error(e)
@@ -407,7 +399,6 @@ module Google
407
399
 
408
400
  @operations_stub.call_rpc :delete_operation, request, options: options do |response, operation|
409
401
  yield response, operation if block_given?
410
- return response
411
402
  end
412
403
  rescue ::GRPC::BadStatus => e
413
404
  raise ::Google::Cloud::Error.from_error(e)
@@ -422,8 +413,9 @@ module Google
422
413
  # other methods to check whether the cancellation succeeded or whether the
423
414
  # operation completed despite cancellation. On successful cancellation,
424
415
  # the operation is not deleted; instead, it becomes an operation with
425
- # an {::Google::Longrunning::Operation#error Operation.error} value with a {::Google::Rpc::Status#code google.rpc.Status.code} of 1,
426
- # corresponding to `Code.CANCELLED`.
416
+ # an {::Google::Longrunning::Operation#error Operation.error} value with a
417
+ # {::Google::Rpc::Status#code google.rpc.Status.code} of `1`, corresponding to
418
+ # `Code.CANCELLED`.
427
419
  #
428
420
  # @overload cancel_operation(request, options = nil)
429
421
  # Pass arguments to `cancel_operation` via a request object, either of type
@@ -502,7 +494,6 @@ module Google
502
494
 
503
495
  @operations_stub.call_rpc :cancel_operation, request, options: options do |response, operation|
504
496
  yield response, operation if block_given?
505
- return response
506
497
  end
507
498
  rescue ::GRPC::BadStatus => e
508
499
  raise ::Google::Cloud::Error.from_error(e)
@@ -600,7 +591,7 @@ module Google
600
591
  @operations_stub.call_rpc :wait_operation, request, options: options do |response, operation|
601
592
  response = ::Gapic::Operation.new response, @operations_client, options: options
602
593
  yield response, operation if block_given?
603
- return response
594
+ throw :response, response
604
595
  end
605
596
  rescue ::GRPC::BadStatus => e
606
597
  raise ::Google::Cloud::Error.from_error(e)
@@ -689,6 +680,11 @@ module Google
689
680
  # default endpoint URL. The default value of nil uses the environment
690
681
  # universe (usually the default "googleapis.com" universe).
691
682
  # @return [::String,nil]
683
+ # @!attribute [rw] logger
684
+ # A custom logger to use for request/response debug logging, or the value
685
+ # `:default` (the default) to construct a default logger, or `nil` to
686
+ # explicitly disable logging.
687
+ # @return [::Logger,:default,nil]
692
688
  #
693
689
  class Configuration
694
690
  extend ::Gapic::Config
@@ -713,6 +709,7 @@ module Google
713
709
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
714
710
  config_attr :quota_project, nil, ::String, nil
715
711
  config_attr :universe_domain, nil, ::String, nil
712
+ config_attr :logger, :default, ::Logger, nil, :default
716
713
 
717
714
  # @private
718
715
  def initialize parent_config = nil