google-cloud-service_directory-v1beta1 0.15.1 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3249478aa1ff190026b56909d7124e1ed83e3abfcbe067633db3dac6774aba56
4
- data.tar.gz: fb6b079fbb500d1f67a488df4227ccbe0f2d9d5a43e78ab565ebb46640e61d41
3
+ metadata.gz: 2f57f86bcf3a26b3607855b1cc3271d0a819ba308760008d58d5ba6924685a98
4
+ data.tar.gz: 8b1845664be80138eaba3a51376943844d4f59ecb2a1ea5fa2c36db7bbe067f8
5
5
  SHA512:
6
- metadata.gz: 6ba665d92d9e5b00c022de9bef662a083bf41aee21e46196c4a0f8f360fda821563a6965c74c358318605d8cf56685c9c635bae307db56efd5aad285ec3adfff
7
- data.tar.gz: 13994731e05ccf2a0e157ae8216e78f0b3c002958893fe6641db29ba12458ac9ce7c7fe85899fc0efbc64dccc7fd1753902305b5b52dd54c4e0cc07283bdd411
6
+ metadata.gz: f96acc53d709d7f3ec749228f345620776e929b766522db7737104af70f512cf6953a4a903f16bf844e45e53dde747f4c2dcd7383caba357301d9112fd7ddd30
7
+ data.tar.gz: 0b9d41ca550cbd3f39d8f5c9a7f7144ee15517c19781b73fa1e75ee06d178637aaf962ad1e0ddebfdcb12f47d110b75c3d4d9a3614fbb4f77981ef1ed2c58f62
data/README.md CHANGED
@@ -43,33 +43,43 @@ for class and method documentation.
43
43
  See also the [Product Documentation](https://cloud.google.com/service-directory)
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/service_directory/v1beta1"
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::ServiceDirectory::V1beta1::LookupService::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).
@@ -163,14 +163,26 @@ module Google
163
163
  universe_domain: @config.universe_domain,
164
164
  channel_args: @config.channel_args,
165
165
  interceptors: @config.interceptors,
166
- channel_pool_config: @config.channel_pool
166
+ channel_pool_config: @config.channel_pool,
167
+ logger: @config.logger
167
168
  )
168
169
 
170
+ @lookup_service_stub.stub_logger&.info do |entry|
171
+ entry.set_system_name
172
+ entry.set_service
173
+ entry.message = "Created client for #{entry.service}"
174
+ entry.set_credentials_fields credentials
175
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
176
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
177
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
178
+ end
179
+
169
180
  @location_client = Google::Cloud::Location::Locations::Client.new do |config|
170
181
  config.credentials = credentials
171
182
  config.quota_project = @quota_project_id
172
183
  config.endpoint = @lookup_service_stub.endpoint
173
184
  config.universe_domain = @lookup_service_stub.universe_domain
185
+ config.logger = @lookup_service_stub.logger if config.respond_to? :logger=
174
186
  end
175
187
  end
176
188
 
@@ -181,6 +193,15 @@ module Google
181
193
  #
182
194
  attr_reader :location_client
183
195
 
196
+ ##
197
+ # The logger used for request/response debug logging.
198
+ #
199
+ # @return [Logger]
200
+ #
201
+ def logger
202
+ @lookup_service_stub.logger
203
+ end
204
+
184
205
  # Service calls
185
206
 
186
207
  ##
@@ -306,7 +327,6 @@ module Google
306
327
 
307
328
  @lookup_service_stub.call_rpc :resolve_service, request, options: options do |response, operation|
308
329
  yield response, operation if block_given?
309
- return response
310
330
  end
311
331
  rescue ::GRPC::BadStatus => e
312
332
  raise ::Google::Cloud::Error.from_error(e)
@@ -395,6 +415,11 @@ module Google
395
415
  # default endpoint URL. The default value of nil uses the environment
396
416
  # universe (usually the default "googleapis.com" universe).
397
417
  # @return [::String,nil]
418
+ # @!attribute [rw] logger
419
+ # A custom logger to use for request/response debug logging, or the value
420
+ # `:default` (the default) to construct a default logger, or `nil` to
421
+ # explicitly disable logging.
422
+ # @return [::Logger,:default,nil]
398
423
  #
399
424
  class Configuration
400
425
  extend ::Gapic::Config
@@ -419,6 +444,7 @@ module Google
419
444
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
420
445
  config_attr :quota_project, nil, ::String, nil
421
446
  config_attr :universe_domain, nil, ::String, nil
447
+ config_attr :logger, :default, ::Logger, nil, :default
422
448
 
423
449
  # @private
424
450
  def initialize parent_config = nil
@@ -156,15 +156,27 @@ module Google
156
156
  endpoint: @config.endpoint,
157
157
  endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
158
158
  universe_domain: @config.universe_domain,
159
- credentials: credentials
159
+ credentials: credentials,
160
+ logger: @config.logger
160
161
  )
161
162
 
163
+ @lookup_service_stub.logger(stub: true)&.info do |entry|
164
+ entry.set_system_name
165
+ entry.set_service
166
+ entry.message = "Created client for #{entry.service}"
167
+ entry.set_credentials_fields credentials
168
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
169
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
170
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
171
+ end
172
+
162
173
  @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
163
174
  config.credentials = credentials
164
175
  config.quota_project = @quota_project_id
165
176
  config.endpoint = @lookup_service_stub.endpoint
166
177
  config.universe_domain = @lookup_service_stub.universe_domain
167
178
  config.bindings_override = @config.bindings_override
179
+ config.logger = @lookup_service_stub.logger if config.respond_to? :logger=
168
180
  end
169
181
  end
170
182
 
@@ -175,6 +187,15 @@ module Google
175
187
  #
176
188
  attr_reader :location_client
177
189
 
190
+ ##
191
+ # The logger used for request/response debug logging.
192
+ #
193
+ # @return [Logger]
194
+ #
195
+ def logger
196
+ @lookup_service_stub.logger
197
+ end
198
+
178
199
  # Service calls
179
200
 
180
201
  ##
@@ -293,7 +314,6 @@ module Google
293
314
 
294
315
  @lookup_service_stub.resolve_service request, options do |result, operation|
295
316
  yield result, operation if block_given?
296
- return result
297
317
  end
298
318
  rescue ::Gapic::Rest::Error => e
299
319
  raise ::Google::Cloud::Error.from_error(e)
@@ -373,6 +393,11 @@ module Google
373
393
  # default endpoint URL. The default value of nil uses the environment
374
394
  # universe (usually the default "googleapis.com" universe).
375
395
  # @return [::String,nil]
396
+ # @!attribute [rw] logger
397
+ # A custom logger to use for request/response debug logging, or the value
398
+ # `:default` (the default) to construct a default logger, or `nil` to
399
+ # explicitly disable logging.
400
+ # @return [::Logger,:default,nil]
376
401
  #
377
402
  class Configuration
378
403
  extend ::Gapic::Config
@@ -401,6 +426,7 @@ module Google
401
426
  # by the host service.
402
427
  # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
403
428
  config_attr :bindings_override, {}, ::Hash, nil
429
+ config_attr :logger, :default, ::Logger, nil, :default
404
430
 
405
431
  # @private
406
432
  def initialize parent_config = nil
@@ -30,7 +30,8 @@ module Google
30
30
  # including transcoding, making the REST call, and deserialing the response.
31
31
  #
32
32
  class ServiceStub
33
- def initialize endpoint:, endpoint_template:, universe_domain:, credentials:
33
+ # @private
34
+ def initialize endpoint:, endpoint_template:, universe_domain:, credentials:, logger:
34
35
  # These require statements are intentionally placed here to initialize
35
36
  # the REST modules only when it's required.
36
37
  require "gapic/rest"
@@ -40,7 +41,9 @@ module Google
40
41
  universe_domain: universe_domain,
41
42
  credentials: credentials,
42
43
  numeric_enums: true,
43
- raise_faraday_errors: false
44
+ service_name: self.class,
45
+ raise_faraday_errors: false,
46
+ logger: logger
44
47
  end
45
48
 
46
49
  ##
@@ -61,6 +64,15 @@ module Google
61
64
  @client_stub.endpoint
62
65
  end
63
66
 
67
+ ##
68
+ # The logger used for request/response debug logging.
69
+ #
70
+ # @return [Logger]
71
+ #
72
+ def logger stub: false
73
+ stub ? @client_stub.stub_logger : @client_stub.logger
74
+ end
75
+
64
76
  ##
65
77
  # Baseline implementation for the resolve_service REST call
66
78
  #
@@ -87,16 +99,18 @@ module Google
87
99
 
88
100
  response = @client_stub.make_http_request(
89
101
  verb,
90
- uri: uri,
91
- body: body || "",
92
- params: query_string_params,
102
+ uri: uri,
103
+ body: body || "",
104
+ params: query_string_params,
105
+ method_name: "resolve_service",
93
106
  options: options
94
107
  )
95
108
  operation = ::Gapic::Rest::TransportOperation.new response
96
109
  result = ::Google::Cloud::ServiceDirectory::V1beta1::ResolveServiceResponse.decode_json response.body, ignore_unknown_fields: true
97
-
98
- yield result, operation if block_given?
99
- result
110
+ catch :response do
111
+ yield result, operation if block_given?
112
+ result
113
+ end
100
114
  end
101
115
 
102
116
  ##
@@ -177,14 +177,26 @@ module Google
177
177
  universe_domain: @config.universe_domain,
178
178
  channel_args: @config.channel_args,
179
179
  interceptors: @config.interceptors,
180
- channel_pool_config: @config.channel_pool
180
+ channel_pool_config: @config.channel_pool,
181
+ logger: @config.logger
181
182
  )
182
183
 
184
+ @registration_service_stub.stub_logger&.info do |entry|
185
+ entry.set_system_name
186
+ entry.set_service
187
+ entry.message = "Created client for #{entry.service}"
188
+ entry.set_credentials_fields credentials
189
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
190
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
191
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
192
+ end
193
+
183
194
  @location_client = Google::Cloud::Location::Locations::Client.new do |config|
184
195
  config.credentials = credentials
185
196
  config.quota_project = @quota_project_id
186
197
  config.endpoint = @registration_service_stub.endpoint
187
198
  config.universe_domain = @registration_service_stub.universe_domain
199
+ config.logger = @registration_service_stub.logger if config.respond_to? :logger=
188
200
  end
189
201
  end
190
202
 
@@ -195,6 +207,15 @@ module Google
195
207
  #
196
208
  attr_reader :location_client
197
209
 
210
+ ##
211
+ # The logger used for request/response debug logging.
212
+ #
213
+ # @return [Logger]
214
+ #
215
+ def logger
216
+ @registration_service_stub.logger
217
+ end
218
+
198
219
  # Service calls
199
220
 
200
221
  ##
@@ -288,7 +309,6 @@ module Google
288
309
 
289
310
  @registration_service_stub.call_rpc :create_namespace, request, options: options do |response, operation|
290
311
  yield response, operation if block_given?
291
- return response
292
312
  end
293
313
  rescue ::GRPC::BadStatus => e
294
314
  raise ::Google::Cloud::Error.from_error(e)
@@ -427,7 +447,7 @@ module Google
427
447
  @registration_service_stub.call_rpc :list_namespaces, request, options: options do |response, operation|
428
448
  response = ::Gapic::PagedEnumerable.new @registration_service_stub, :list_namespaces, request, response, operation, options
429
449
  yield response, operation if block_given?
430
- return response
450
+ throw :response, response
431
451
  end
432
452
  rescue ::GRPC::BadStatus => e
433
453
  raise ::Google::Cloud::Error.from_error(e)
@@ -513,7 +533,6 @@ module Google
513
533
 
514
534
  @registration_service_stub.call_rpc :get_namespace, request, options: options do |response, operation|
515
535
  yield response, operation if block_given?
516
- return response
517
536
  end
518
537
  rescue ::GRPC::BadStatus => e
519
538
  raise ::Google::Cloud::Error.from_error(e)
@@ -601,7 +620,6 @@ module Google
601
620
 
602
621
  @registration_service_stub.call_rpc :update_namespace, request, options: options do |response, operation|
603
622
  yield response, operation if block_given?
604
- return response
605
623
  end
606
624
  rescue ::GRPC::BadStatus => e
607
625
  raise ::Google::Cloud::Error.from_error(e)
@@ -688,7 +706,6 @@ module Google
688
706
 
689
707
  @registration_service_stub.call_rpc :delete_namespace, request, options: options do |response, operation|
690
708
  yield response, operation if block_given?
691
- return response
692
709
  end
693
710
  rescue ::GRPC::BadStatus => e
694
711
  raise ::Google::Cloud::Error.from_error(e)
@@ -784,7 +801,6 @@ module Google
784
801
 
785
802
  @registration_service_stub.call_rpc :create_service, request, options: options do |response, operation|
786
803
  yield response, operation if block_given?
787
- return response
788
804
  end
789
805
  rescue ::GRPC::BadStatus => e
790
806
  raise ::Google::Cloud::Error.from_error(e)
@@ -926,7 +942,7 @@ module Google
926
942
  @registration_service_stub.call_rpc :list_services, request, options: options do |response, operation|
927
943
  response = ::Gapic::PagedEnumerable.new @registration_service_stub, :list_services, request, response, operation, options
928
944
  yield response, operation if block_given?
929
- return response
945
+ throw :response, response
930
946
  end
931
947
  rescue ::GRPC::BadStatus => e
932
948
  raise ::Google::Cloud::Error.from_error(e)
@@ -1012,7 +1028,6 @@ module Google
1012
1028
 
1013
1029
  @registration_service_stub.call_rpc :get_service, request, options: options do |response, operation|
1014
1030
  yield response, operation if block_given?
1015
- return response
1016
1031
  end
1017
1032
  rescue ::GRPC::BadStatus => e
1018
1033
  raise ::Google::Cloud::Error.from_error(e)
@@ -1100,7 +1115,6 @@ module Google
1100
1115
 
1101
1116
  @registration_service_stub.call_rpc :update_service, request, options: options do |response, operation|
1102
1117
  yield response, operation if block_given?
1103
- return response
1104
1118
  end
1105
1119
  rescue ::GRPC::BadStatus => e
1106
1120
  raise ::Google::Cloud::Error.from_error(e)
@@ -1187,7 +1201,6 @@ module Google
1187
1201
 
1188
1202
  @registration_service_stub.call_rpc :delete_service, request, options: options do |response, operation|
1189
1203
  yield response, operation if block_given?
1190
- return response
1191
1204
  end
1192
1205
  rescue ::GRPC::BadStatus => e
1193
1206
  raise ::Google::Cloud::Error.from_error(e)
@@ -1283,7 +1296,6 @@ module Google
1283
1296
 
1284
1297
  @registration_service_stub.call_rpc :create_endpoint, request, options: options do |response, operation|
1285
1298
  yield response, operation if block_given?
1286
- return response
1287
1299
  end
1288
1300
  rescue ::GRPC::BadStatus => e
1289
1301
  raise ::Google::Cloud::Error.from_error(e)
@@ -1427,7 +1439,7 @@ module Google
1427
1439
  @registration_service_stub.call_rpc :list_endpoints, request, options: options do |response, operation|
1428
1440
  response = ::Gapic::PagedEnumerable.new @registration_service_stub, :list_endpoints, request, response, operation, options
1429
1441
  yield response, operation if block_given?
1430
- return response
1442
+ throw :response, response
1431
1443
  end
1432
1444
  rescue ::GRPC::BadStatus => e
1433
1445
  raise ::Google::Cloud::Error.from_error(e)
@@ -1513,7 +1525,6 @@ module Google
1513
1525
 
1514
1526
  @registration_service_stub.call_rpc :get_endpoint, request, options: options do |response, operation|
1515
1527
  yield response, operation if block_given?
1516
- return response
1517
1528
  end
1518
1529
  rescue ::GRPC::BadStatus => e
1519
1530
  raise ::Google::Cloud::Error.from_error(e)
@@ -1601,7 +1612,6 @@ module Google
1601
1612
 
1602
1613
  @registration_service_stub.call_rpc :update_endpoint, request, options: options do |response, operation|
1603
1614
  yield response, operation if block_given?
1604
- return response
1605
1615
  end
1606
1616
  rescue ::GRPC::BadStatus => e
1607
1617
  raise ::Google::Cloud::Error.from_error(e)
@@ -1687,7 +1697,6 @@ module Google
1687
1697
 
1688
1698
  @registration_service_stub.call_rpc :delete_endpoint, request, options: options do |response, operation|
1689
1699
  yield response, operation if block_given?
1690
- return response
1691
1700
  end
1692
1701
  rescue ::GRPC::BadStatus => e
1693
1702
  raise ::Google::Cloud::Error.from_error(e)
@@ -1777,7 +1786,6 @@ module Google
1777
1786
 
1778
1787
  @registration_service_stub.call_rpc :get_iam_policy, request, options: options do |response, operation|
1779
1788
  yield response, operation if block_given?
1780
- return response
1781
1789
  end
1782
1790
  rescue ::GRPC::BadStatus => e
1783
1791
  raise ::Google::Cloud::Error.from_error(e)
@@ -1875,7 +1883,6 @@ module Google
1875
1883
 
1876
1884
  @registration_service_stub.call_rpc :set_iam_policy, request, options: options do |response, operation|
1877
1885
  yield response, operation if block_given?
1878
- return response
1879
1886
  end
1880
1887
  rescue ::GRPC::BadStatus => e
1881
1888
  raise ::Google::Cloud::Error.from_error(e)
@@ -1968,7 +1975,6 @@ module Google
1968
1975
 
1969
1976
  @registration_service_stub.call_rpc :test_iam_permissions, request, options: options do |response, operation|
1970
1977
  yield response, operation if block_given?
1971
- return response
1972
1978
  end
1973
1979
  rescue ::GRPC::BadStatus => e
1974
1980
  raise ::Google::Cloud::Error.from_error(e)
@@ -2057,6 +2063,11 @@ module Google
2057
2063
  # default endpoint URL. The default value of nil uses the environment
2058
2064
  # universe (usually the default "googleapis.com" universe).
2059
2065
  # @return [::String,nil]
2066
+ # @!attribute [rw] logger
2067
+ # A custom logger to use for request/response debug logging, or the value
2068
+ # `:default` (the default) to construct a default logger, or `nil` to
2069
+ # explicitly disable logging.
2070
+ # @return [::Logger,:default,nil]
2060
2071
  #
2061
2072
  class Configuration
2062
2073
  extend ::Gapic::Config
@@ -2081,6 +2092,7 @@ module Google
2081
2092
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
2082
2093
  config_attr :quota_project, nil, ::String, nil
2083
2094
  config_attr :universe_domain, nil, ::String, nil
2095
+ config_attr :logger, :default, ::Logger, nil, :default
2084
2096
 
2085
2097
  # @private
2086
2098
  def initialize parent_config = nil