google-cloud-discovery_engine-v1beta 0.16.0 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +31 -21
  3. data/lib/google/cloud/discovery_engine/v1beta/completion_service/client.rb +49 -7
  4. data/lib/google/cloud/discovery_engine/v1beta/completion_service/operations.rb +19 -15
  5. data/lib/google/cloud/discovery_engine/v1beta/completion_service/rest/client.rb +49 -7
  6. data/lib/google/cloud/discovery_engine/v1beta/completion_service/rest/operations.rb +50 -38
  7. data/lib/google/cloud/discovery_engine/v1beta/completion_service/rest/service_stub.rb +62 -38
  8. data/lib/google/cloud/discovery_engine/v1beta/control_service/client.rb +36 -6
  9. data/lib/google/cloud/discovery_engine/v1beta/control_service/rest/client.rb +36 -6
  10. data/lib/google/cloud/discovery_engine/v1beta/control_service/rest/service_stub.rb +54 -32
  11. data/lib/google/cloud/discovery_engine/v1beta/conversational_search_service/client.rb +37 -14
  12. data/lib/google/cloud/discovery_engine/v1beta/conversational_search_service/rest/client.rb +37 -14
  13. data/lib/google/cloud/discovery_engine/v1beta/conversational_search_service/rest/service_stub.rb +118 -80
  14. data/lib/google/cloud/discovery_engine/v1beta/data_store_service/client.rb +38 -6
  15. data/lib/google/cloud/discovery_engine/v1beta/data_store_service/operations.rb +19 -15
  16. data/lib/google/cloud/discovery_engine/v1beta/data_store_service/rest/client.rb +38 -6
  17. data/lib/google/cloud/discovery_engine/v1beta/data_store_service/rest/operations.rb +50 -38
  18. data/lib/google/cloud/discovery_engine/v1beta/data_store_service/rest/service_stub.rb +54 -32
  19. data/lib/google/cloud/discovery_engine/v1beta/document_service/client.rb +60 -9
  20. data/lib/google/cloud/discovery_engine/v1beta/document_service/operations.rb +19 -15
  21. data/lib/google/cloud/discovery_engine/v1beta/document_service/rest/client.rb +60 -9
  22. data/lib/google/cloud/discovery_engine/v1beta/document_service/rest/operations.rb +50 -38
  23. data/lib/google/cloud/discovery_engine/v1beta/document_service/rest/service_stub.rb +78 -50
  24. data/lib/google/cloud/discovery_engine/v1beta/engine_service/client.rb +39 -9
  25. data/lib/google/cloud/discovery_engine/v1beta/engine_service/operations.rb +19 -15
  26. data/lib/google/cloud/discovery_engine/v1beta/engine_service/rest/client.rb +39 -9
  27. data/lib/google/cloud/discovery_engine/v1beta/engine_service/rest/operations.rb +50 -38
  28. data/lib/google/cloud/discovery_engine/v1beta/engine_service/rest/service_stub.rb +78 -50
  29. data/lib/google/cloud/discovery_engine/v1beta/evaluation_service/client.rb +38 -5
  30. data/lib/google/cloud/discovery_engine/v1beta/evaluation_service/operations.rb +19 -15
  31. data/lib/google/cloud/discovery_engine/v1beta/evaluation_service/rest/client.rb +38 -5
  32. data/lib/google/cloud/discovery_engine/v1beta/evaluation_service/rest/operations.rb +50 -38
  33. data/lib/google/cloud/discovery_engine/v1beta/evaluation_service/rest/service_stub.rb +46 -26
  34. data/lib/google/cloud/discovery_engine/v1beta/grounded_generation_service/client.rb +35 -4
  35. data/lib/google/cloud/discovery_engine/v1beta/grounded_generation_service/rest/client.rb +35 -3
  36. data/lib/google/cloud/discovery_engine/v1beta/grounded_generation_service/rest/service_stub.rb +30 -14
  37. data/lib/google/cloud/discovery_engine/v1beta/project_service/client.rb +36 -2
  38. data/lib/google/cloud/discovery_engine/v1beta/project_service/operations.rb +19 -15
  39. data/lib/google/cloud/discovery_engine/v1beta/project_service/rest/client.rb +36 -2
  40. data/lib/google/cloud/discovery_engine/v1beta/project_service/rest/operations.rb +50 -38
  41. data/lib/google/cloud/discovery_engine/v1beta/project_service/rest/service_stub.rb +22 -8
  42. data/lib/google/cloud/discovery_engine/v1beta/rank_service/client.rb +35 -2
  43. data/lib/google/cloud/discovery_engine/v1beta/rank_service/rest/client.rb +35 -2
  44. data/lib/google/cloud/discovery_engine/v1beta/rank_service/rest/service_stub.rb +22 -8
  45. data/lib/google/cloud/discovery_engine/v1beta/recommendation_service/client.rb +35 -2
  46. data/lib/google/cloud/discovery_engine/v1beta/recommendation_service/rest/client.rb +35 -2
  47. data/lib/google/cloud/discovery_engine/v1beta/recommendation_service/rest/service_stub.rb +22 -8
  48. data/lib/google/cloud/discovery_engine/v1beta/sample_query_service/client.rb +43 -7
  49. data/lib/google/cloud/discovery_engine/v1beta/sample_query_service/operations.rb +19 -15
  50. data/lib/google/cloud/discovery_engine/v1beta/sample_query_service/rest/client.rb +43 -7
  51. data/lib/google/cloud/discovery_engine/v1beta/sample_query_service/rest/operations.rb +50 -38
  52. data/lib/google/cloud/discovery_engine/v1beta/sample_query_service/rest/service_stub.rb +62 -38
  53. data/lib/google/cloud/discovery_engine/v1beta/sample_query_set_service/client.rb +36 -6
  54. data/lib/google/cloud/discovery_engine/v1beta/sample_query_set_service/rest/client.rb +36 -6
  55. data/lib/google/cloud/discovery_engine/v1beta/sample_query_set_service/rest/service_stub.rb +54 -32
  56. data/lib/google/cloud/discovery_engine/v1beta/schema_service/client.rb +39 -6
  57. data/lib/google/cloud/discovery_engine/v1beta/schema_service/operations.rb +19 -15
  58. data/lib/google/cloud/discovery_engine/v1beta/schema_service/rest/client.rb +39 -6
  59. data/lib/google/cloud/discovery_engine/v1beta/schema_service/rest/operations.rb +50 -38
  60. data/lib/google/cloud/discovery_engine/v1beta/schema_service/rest/service_stub.rb +54 -32
  61. data/lib/google/cloud/discovery_engine/v1beta/search_service/client.rb +37 -3
  62. data/lib/google/cloud/discovery_engine/v1beta/search_service/rest/client.rb +35 -3
  63. data/lib/google/cloud/discovery_engine/v1beta/search_service/rest/service_stub.rb +30 -14
  64. data/lib/google/cloud/discovery_engine/v1beta/search_tuning_service/client.rb +36 -3
  65. data/lib/google/cloud/discovery_engine/v1beta/search_tuning_service/operations.rb +19 -15
  66. data/lib/google/cloud/discovery_engine/v1beta/search_tuning_service/rest/client.rb +36 -3
  67. data/lib/google/cloud/discovery_engine/v1beta/search_tuning_service/rest/operations.rb +50 -38
  68. data/lib/google/cloud/discovery_engine/v1beta/search_tuning_service/rest/service_stub.rb +30 -14
  69. data/lib/google/cloud/discovery_engine/v1beta/serving_config_service/client.rb +36 -4
  70. data/lib/google/cloud/discovery_engine/v1beta/serving_config_service/rest/client.rb +36 -4
  71. data/lib/google/cloud/discovery_engine/v1beta/serving_config_service/rest/service_stub.rb +38 -20
  72. data/lib/google/cloud/discovery_engine/v1beta/site_search_engine_service/client.rb +47 -16
  73. data/lib/google/cloud/discovery_engine/v1beta/site_search_engine_service/operations.rb +19 -15
  74. data/lib/google/cloud/discovery_engine/v1beta/site_search_engine_service/rest/client.rb +47 -16
  75. data/lib/google/cloud/discovery_engine/v1beta/site_search_engine_service/rest/operations.rb +50 -38
  76. data/lib/google/cloud/discovery_engine/v1beta/site_search_engine_service/rest/service_stub.rb +134 -92
  77. data/lib/google/cloud/discovery_engine/v1beta/user_event_service/client.rb +43 -5
  78. data/lib/google/cloud/discovery_engine/v1beta/user_event_service/operations.rb +19 -15
  79. data/lib/google/cloud/discovery_engine/v1beta/user_event_service/rest/client.rb +43 -5
  80. data/lib/google/cloud/discovery_engine/v1beta/user_event_service/rest/operations.rb +50 -38
  81. data/lib/google/cloud/discovery_engine/v1beta/user_event_service/rest/service_stub.rb +46 -26
  82. data/lib/google/cloud/discovery_engine/v1beta/version.rb +1 -1
  83. data/proto_docs/google/api/client.rb +19 -0
  84. data/proto_docs/google/cloud/discoveryengine/v1beta/answer.rb +6 -0
  85. data/proto_docs/google/cloud/discoveryengine/v1beta/common.rb +8 -0
  86. data/proto_docs/google/cloud/discoveryengine/v1beta/completion.rb +4 -0
  87. data/proto_docs/google/cloud/discoveryengine/v1beta/control.rb +8 -0
  88. data/proto_docs/google/cloud/discoveryengine/v1beta/conversation.rb +4 -0
  89. data/proto_docs/google/cloud/discoveryengine/v1beta/conversational_search_service.rb +8 -0
  90. data/proto_docs/google/cloud/discoveryengine/v1beta/document.rb +8 -0
  91. data/proto_docs/google/cloud/discoveryengine/v1beta/document_processing_config.rb +6 -0
  92. data/proto_docs/google/cloud/discoveryengine/v1beta/document_service.rb +8 -0
  93. data/proto_docs/google/cloud/discoveryengine/v1beta/engine.rb +4 -0
  94. data/proto_docs/google/cloud/discoveryengine/v1beta/grounded_generation_service.rb +6 -0
  95. data/proto_docs/google/cloud/discoveryengine/v1beta/import_config.rb +40 -0
  96. data/proto_docs/google/cloud/discoveryengine/v1beta/purge_config.rb +4 -0
  97. data/proto_docs/google/cloud/discoveryengine/v1beta/schema.rb +4 -0
  98. data/proto_docs/google/cloud/discoveryengine/v1beta/search_service.rb +14 -0
  99. data/proto_docs/google/cloud/discoveryengine/v1beta/serving_config.rb +8 -0
  100. data/proto_docs/google/cloud/discoveryengine/v1beta/user_event.rb +6 -0
  101. data/proto_docs/google/longrunning/operations.rb +23 -14
  102. data/proto_docs/google/protobuf/struct.rb +12 -0
  103. metadata +6 -9
@@ -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
+ @rank_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 = @rank_service_stub.endpoint
173
184
  config.universe_domain = @rank_service_stub.universe_domain
185
+ config.logger = @rank_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
+ @rank_service_stub.logger
203
+ end
204
+
184
205
  # Service calls
185
206
 
186
207
  ##
@@ -299,7 +320,6 @@ module Google
299
320
 
300
321
  @rank_service_stub.call_rpc :rank, request, options: options do |response, operation|
301
322
  yield response, operation if block_given?
302
- return response
303
323
  end
304
324
  rescue ::GRPC::BadStatus => e
305
325
  raise ::Google::Cloud::Error.from_error(e)
@@ -349,6 +369,13 @@ module Google
349
369
  # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
350
370
  # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
351
371
  # * (`nil`) indicating no credentials
372
+ #
373
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
374
+ # external source for authentication to Google Cloud, you must validate it before
375
+ # providing it to a Google API client library. Providing an unvalidated credential
376
+ # configuration to Google APIs can compromise the security of your systems and data.
377
+ # For more information, refer to [Validate credential configurations from external
378
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
352
379
  # @return [::Object]
353
380
  # @!attribute [rw] scope
354
381
  # The OAuth scopes
@@ -388,6 +415,11 @@ module Google
388
415
  # default endpoint URL. The default value of nil uses the environment
389
416
  # universe (usually the default "googleapis.com" universe).
390
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]
391
423
  #
392
424
  class Configuration
393
425
  extend ::Gapic::Config
@@ -412,6 +444,7 @@ module Google
412
444
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
413
445
  config_attr :quota_project, nil, ::String, nil
414
446
  config_attr :universe_domain, nil, ::String, nil
447
+ config_attr :logger, :default, ::Logger, nil, :default
415
448
 
416
449
  # @private
417
450
  def initialize parent_config = nil
@@ -156,14 +156,26 @@ 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
+ @rank_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 = @rank_service_stub.endpoint
166
177
  config.universe_domain = @rank_service_stub.universe_domain
178
+ config.logger = @rank_service_stub.logger if config.respond_to? :logger=
167
179
  end
168
180
  end
169
181
 
@@ -174,6 +186,15 @@ module Google
174
186
  #
175
187
  attr_reader :location_client
176
188
 
189
+ ##
190
+ # The logger used for request/response debug logging.
191
+ #
192
+ # @return [Logger]
193
+ #
194
+ def logger
195
+ @rank_service_stub.logger
196
+ end
197
+
177
198
  # Service calls
178
199
 
179
200
  ##
@@ -285,7 +306,6 @@ module Google
285
306
 
286
307
  @rank_service_stub.rank request, options do |result, operation|
287
308
  yield result, operation if block_given?
288
- return result
289
309
  end
290
310
  rescue ::Gapic::Rest::Error => e
291
311
  raise ::Google::Cloud::Error.from_error(e)
@@ -333,6 +353,13 @@ module Google
333
353
  # * (`Signet::OAuth2::Client`) A signet oauth2 client object
334
354
  # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
335
355
  # * (`nil`) indicating no credentials
356
+ #
357
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
358
+ # external source for authentication to Google Cloud, you must validate it before
359
+ # providing it to a Google API client library. Providing an unvalidated credential
360
+ # configuration to Google APIs can compromise the security of your systems and data.
361
+ # For more information, refer to [Validate credential configurations from external
362
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
336
363
  # @return [::Object]
337
364
  # @!attribute [rw] scope
338
365
  # The OAuth scopes
@@ -365,6 +392,11 @@ module Google
365
392
  # default endpoint URL. The default value of nil uses the environment
366
393
  # universe (usually the default "googleapis.com" universe).
367
394
  # @return [::String,nil]
395
+ # @!attribute [rw] logger
396
+ # A custom logger to use for request/response debug logging, or the value
397
+ # `:default` (the default) to construct a default logger, or `nil` to
398
+ # explicitly disable logging.
399
+ # @return [::Logger,:default,nil]
368
400
  #
369
401
  class Configuration
370
402
  extend ::Gapic::Config
@@ -386,6 +418,7 @@ module Google
386
418
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
387
419
  config_attr :quota_project, nil, ::String, nil
388
420
  config_attr :universe_domain, nil, ::String, nil
421
+ config_attr :logger, :default, ::Logger, nil, :default
389
422
 
390
423
  # @private
391
424
  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 rank 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: "rank",
93
106
  options: options
94
107
  )
95
108
  operation = ::Gapic::Rest::TransportOperation.new response
96
109
  result = ::Google::Cloud::DiscoveryEngine::V1beta::RankResponse.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
  ##
@@ -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
+ @recommendation_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 = @recommendation_service_stub.endpoint
173
184
  config.universe_domain = @recommendation_service_stub.universe_domain
185
+ config.logger = @recommendation_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
+ @recommendation_service_stub.logger
203
+ end
204
+
184
205
  # Service calls
185
206
 
186
207
  ##
@@ -377,7 +398,6 @@ module Google
377
398
 
378
399
  @recommendation_service_stub.call_rpc :recommend, request, options: options do |response, operation|
379
400
  yield response, operation if block_given?
380
- return response
381
401
  end
382
402
  rescue ::GRPC::BadStatus => e
383
403
  raise ::Google::Cloud::Error.from_error(e)
@@ -427,6 +447,13 @@ module Google
427
447
  # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
428
448
  # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
429
449
  # * (`nil`) indicating no credentials
450
+ #
451
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
452
+ # external source for authentication to Google Cloud, you must validate it before
453
+ # providing it to a Google API client library. Providing an unvalidated credential
454
+ # configuration to Google APIs can compromise the security of your systems and data.
455
+ # For more information, refer to [Validate credential configurations from external
456
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
430
457
  # @return [::Object]
431
458
  # @!attribute [rw] scope
432
459
  # The OAuth scopes
@@ -466,6 +493,11 @@ module Google
466
493
  # default endpoint URL. The default value of nil uses the environment
467
494
  # universe (usually the default "googleapis.com" universe).
468
495
  # @return [::String,nil]
496
+ # @!attribute [rw] logger
497
+ # A custom logger to use for request/response debug logging, or the value
498
+ # `:default` (the default) to construct a default logger, or `nil` to
499
+ # explicitly disable logging.
500
+ # @return [::Logger,:default,nil]
469
501
  #
470
502
  class Configuration
471
503
  extend ::Gapic::Config
@@ -490,6 +522,7 @@ module Google
490
522
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
491
523
  config_attr :quota_project, nil, ::String, nil
492
524
  config_attr :universe_domain, nil, ::String, nil
525
+ config_attr :logger, :default, ::Logger, nil, :default
493
526
 
494
527
  # @private
495
528
  def initialize parent_config = nil
@@ -156,14 +156,26 @@ 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
+ @recommendation_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 = @recommendation_service_stub.endpoint
166
177
  config.universe_domain = @recommendation_service_stub.universe_domain
178
+ config.logger = @recommendation_service_stub.logger if config.respond_to? :logger=
167
179
  end
168
180
  end
169
181
 
@@ -174,6 +186,15 @@ module Google
174
186
  #
175
187
  attr_reader :location_client
176
188
 
189
+ ##
190
+ # The logger used for request/response debug logging.
191
+ #
192
+ # @return [Logger]
193
+ #
194
+ def logger
195
+ @recommendation_service_stub.logger
196
+ end
197
+
177
198
  # Service calls
178
199
 
179
200
  ##
@@ -363,7 +384,6 @@ module Google
363
384
 
364
385
  @recommendation_service_stub.recommend request, options do |result, operation|
365
386
  yield result, operation if block_given?
366
- return result
367
387
  end
368
388
  rescue ::Gapic::Rest::Error => e
369
389
  raise ::Google::Cloud::Error.from_error(e)
@@ -411,6 +431,13 @@ module Google
411
431
  # * (`Signet::OAuth2::Client`) A signet oauth2 client object
412
432
  # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
413
433
  # * (`nil`) indicating no credentials
434
+ #
435
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
436
+ # external source for authentication to Google Cloud, you must validate it before
437
+ # providing it to a Google API client library. Providing an unvalidated credential
438
+ # configuration to Google APIs can compromise the security of your systems and data.
439
+ # For more information, refer to [Validate credential configurations from external
440
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
414
441
  # @return [::Object]
415
442
  # @!attribute [rw] scope
416
443
  # The OAuth scopes
@@ -443,6 +470,11 @@ module Google
443
470
  # default endpoint URL. The default value of nil uses the environment
444
471
  # universe (usually the default "googleapis.com" universe).
445
472
  # @return [::String,nil]
473
+ # @!attribute [rw] logger
474
+ # A custom logger to use for request/response debug logging, or the value
475
+ # `:default` (the default) to construct a default logger, or `nil` to
476
+ # explicitly disable logging.
477
+ # @return [::Logger,:default,nil]
446
478
  #
447
479
  class Configuration
448
480
  extend ::Gapic::Config
@@ -464,6 +496,7 @@ module Google
464
496
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
465
497
  config_attr :quota_project, nil, ::String, nil
466
498
  config_attr :universe_domain, nil, ::String, nil
499
+ config_attr :logger, :default, ::Logger, nil, :default
467
500
 
468
501
  # @private
469
502
  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 recommend 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: "recommend",
93
106
  options: options
94
107
  )
95
108
  operation = ::Gapic::Rest::TransportOperation.new response
96
109
  result = ::Google::Cloud::DiscoveryEngine::V1beta::RecommendResponse.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
  ##
@@ -171,14 +171,26 @@ module Google
171
171
  universe_domain: @config.universe_domain,
172
172
  channel_args: @config.channel_args,
173
173
  interceptors: @config.interceptors,
174
- channel_pool_config: @config.channel_pool
174
+ channel_pool_config: @config.channel_pool,
175
+ logger: @config.logger
175
176
  )
176
177
 
178
+ @sample_query_service_stub.stub_logger&.info do |entry|
179
+ entry.set_system_name
180
+ entry.set_service
181
+ entry.message = "Created client for #{entry.service}"
182
+ entry.set_credentials_fields credentials
183
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
184
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
185
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
186
+ end
187
+
177
188
  @location_client = Google::Cloud::Location::Locations::Client.new do |config|
178
189
  config.credentials = credentials
179
190
  config.quota_project = @quota_project_id
180
191
  config.endpoint = @sample_query_service_stub.endpoint
181
192
  config.universe_domain = @sample_query_service_stub.universe_domain
193
+ config.logger = @sample_query_service_stub.logger if config.respond_to? :logger=
182
194
  end
183
195
  end
184
196
 
@@ -196,6 +208,15 @@ module Google
196
208
  #
197
209
  attr_reader :location_client
198
210
 
211
+ ##
212
+ # The logger used for request/response debug logging.
213
+ #
214
+ # @return [Logger]
215
+ #
216
+ def logger
217
+ @sample_query_service_stub.logger
218
+ end
219
+
199
220
  # Service calls
200
221
 
201
222
  ##
@@ -288,7 +309,6 @@ module Google
288
309
 
289
310
  @sample_query_service_stub.call_rpc :get_sample_query, 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)
@@ -404,7 +424,7 @@ module Google
404
424
  @sample_query_service_stub.call_rpc :list_sample_queries, request, options: options do |response, operation|
405
425
  response = ::Gapic::PagedEnumerable.new @sample_query_service_stub, :list_sample_queries, request, response, operation, options
406
426
  yield response, operation if block_given?
407
- return response
427
+ throw :response, response
408
428
  end
409
429
  rescue ::GRPC::BadStatus => e
410
430
  raise ::Google::Cloud::Error.from_error(e)
@@ -513,7 +533,6 @@ module Google
513
533
 
514
534
  @sample_query_service_stub.call_rpc :create_sample_query, 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)
@@ -609,7 +628,6 @@ module Google
609
628
 
610
629
  @sample_query_service_stub.call_rpc :update_sample_query, request, options: options do |response, operation|
611
630
  yield response, operation if block_given?
612
- return response
613
631
  end
614
632
  rescue ::GRPC::BadStatus => e
615
633
  raise ::Google::Cloud::Error.from_error(e)
@@ -704,7 +722,6 @@ module Google
704
722
 
705
723
  @sample_query_service_stub.call_rpc :delete_sample_query, request, options: options do |response, operation|
706
724
  yield response, operation if block_given?
707
- return response
708
725
  end
709
726
  rescue ::GRPC::BadStatus => e
710
727
  raise ::Google::Cloud::Error.from_error(e)
@@ -736,10 +753,16 @@ module Google
736
753
  #
737
754
  # @param inline_source [::Google::Cloud::DiscoveryEngine::V1beta::ImportSampleQueriesRequest::InlineSource, ::Hash]
738
755
  # The Inline source for sample query entries.
756
+ #
757
+ # Note: The following fields are mutually exclusive: `inline_source`, `gcs_source`, `bigquery_source`. If a field in that set is populated, all other fields in the set will automatically be cleared.
739
758
  # @param gcs_source [::Google::Cloud::DiscoveryEngine::V1beta::GcsSource, ::Hash]
740
759
  # Cloud Storage location for the input content.
760
+ #
761
+ # Note: The following fields are mutually exclusive: `gcs_source`, `inline_source`, `bigquery_source`. If a field in that set is populated, all other fields in the set will automatically be cleared.
741
762
  # @param bigquery_source [::Google::Cloud::DiscoveryEngine::V1beta::BigQuerySource, ::Hash]
742
763
  # BigQuery input source.
764
+ #
765
+ # Note: The following fields are mutually exclusive: `bigquery_source`, `inline_source`, `gcs_source`. If a field in that set is populated, all other fields in the set will automatically be cleared.
743
766
  # @param parent [::String]
744
767
  # Required. The parent sample query set resource name, such as
745
768
  # `projects/{project}/locations/{location}/sampleQuerySets/{sampleQuerySet}`.
@@ -818,7 +841,7 @@ module Google
818
841
  @sample_query_service_stub.call_rpc :import_sample_queries, request, options: options do |response, operation|
819
842
  response = ::Gapic::Operation.new response, @operations_client, options: options
820
843
  yield response, operation if block_given?
821
- return response
844
+ throw :response, response
822
845
  end
823
846
  rescue ::GRPC::BadStatus => e
824
847
  raise ::Google::Cloud::Error.from_error(e)
@@ -868,6 +891,13 @@ module Google
868
891
  # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
869
892
  # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
870
893
  # * (`nil`) indicating no credentials
894
+ #
895
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
896
+ # external source for authentication to Google Cloud, you must validate it before
897
+ # providing it to a Google API client library. Providing an unvalidated credential
898
+ # configuration to Google APIs can compromise the security of your systems and data.
899
+ # For more information, refer to [Validate credential configurations from external
900
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
871
901
  # @return [::Object]
872
902
  # @!attribute [rw] scope
873
903
  # The OAuth scopes
@@ -907,6 +937,11 @@ module Google
907
937
  # default endpoint URL. The default value of nil uses the environment
908
938
  # universe (usually the default "googleapis.com" universe).
909
939
  # @return [::String,nil]
940
+ # @!attribute [rw] logger
941
+ # A custom logger to use for request/response debug logging, or the value
942
+ # `:default` (the default) to construct a default logger, or `nil` to
943
+ # explicitly disable logging.
944
+ # @return [::Logger,:default,nil]
910
945
  #
911
946
  class Configuration
912
947
  extend ::Gapic::Config
@@ -931,6 +966,7 @@ module Google
931
966
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
932
967
  config_attr :quota_project, nil, ::String, nil
933
968
  config_attr :universe_domain, nil, ::String, nil
969
+ config_attr :logger, :default, ::Logger, nil, :default
934
970
 
935
971
  # @private
936
972
  def initialize parent_config = nil