google-cloud-dialogflow-cx-v3 1.2.0 → 1.4.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.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +31 -21
  3. data/lib/google/cloud/dialogflow/cx/v3/agents/client.rb +44 -12
  4. data/lib/google/cloud/dialogflow/cx/v3/agents/operations.rb +19 -15
  5. data/lib/google/cloud/dialogflow/cx/v3/agents/rest/client.rb +44 -12
  6. data/lib/google/cloud/dialogflow/cx/v3/agents/rest/operations.rb +50 -38
  7. data/lib/google/cloud/dialogflow/cx/v3/agents/rest/service_stub.rb +102 -68
  8. data/lib/google/cloud/dialogflow/cx/v3/changelogs/client.rb +36 -3
  9. data/lib/google/cloud/dialogflow/cx/v3/changelogs/rest/client.rb +36 -3
  10. data/lib/google/cloud/dialogflow/cx/v3/changelogs/rest/service_stub.rb +30 -14
  11. data/lib/google/cloud/dialogflow/cx/v3/deployments/client.rb +36 -3
  12. data/lib/google/cloud/dialogflow/cx/v3/deployments/rest/client.rb +36 -3
  13. data/lib/google/cloud/dialogflow/cx/v3/deployments/rest/service_stub.rb +30 -14
  14. data/lib/google/cloud/dialogflow/cx/v3/entity_types/client.rb +46 -8
  15. data/lib/google/cloud/dialogflow/cx/v3/entity_types/operations.rb +19 -15
  16. data/lib/google/cloud/dialogflow/cx/v3/entity_types/rest/client.rb +46 -8
  17. data/lib/google/cloud/dialogflow/cx/v3/entity_types/rest/operations.rb +50 -38
  18. data/lib/google/cloud/dialogflow/cx/v3/entity_types/rest/service_stub.rb +70 -44
  19. data/lib/google/cloud/dialogflow/cx/v3/environments/client.rb +42 -10
  20. data/lib/google/cloud/dialogflow/cx/v3/environments/operations.rb +19 -15
  21. data/lib/google/cloud/dialogflow/cx/v3/environments/rest/client.rb +42 -10
  22. data/lib/google/cloud/dialogflow/cx/v3/environments/rest/operations.rb +50 -38
  23. data/lib/google/cloud/dialogflow/cx/v3/environments/rest/service_stub.rb +86 -56
  24. data/lib/google/cloud/dialogflow/cx/v3/experiments/client.rb +36 -8
  25. data/lib/google/cloud/dialogflow/cx/v3/experiments/rest/client.rb +36 -8
  26. data/lib/google/cloud/dialogflow/cx/v3/experiments/rest/service_stub.rb +70 -44
  27. data/lib/google/cloud/dialogflow/cx/v3/flows/client.rb +43 -11
  28. data/lib/google/cloud/dialogflow/cx/v3/flows/operations.rb +19 -15
  29. data/lib/google/cloud/dialogflow/cx/v3/flows/rest/client.rb +43 -11
  30. data/lib/google/cloud/dialogflow/cx/v3/flows/rest/operations.rb +50 -38
  31. data/lib/google/cloud/dialogflow/cx/v3/flows/rest/service_stub.rb +94 -62
  32. data/lib/google/cloud/dialogflow/cx/v3/generators/client.rb +36 -6
  33. data/lib/google/cloud/dialogflow/cx/v3/generators/rest/client.rb +36 -6
  34. data/lib/google/cloud/dialogflow/cx/v3/generators/rest/service_stub.rb +54 -32
  35. data/lib/google/cloud/dialogflow/cx/v3/intents/client.rb +46 -8
  36. data/lib/google/cloud/dialogflow/cx/v3/intents/operations.rb +19 -15
  37. data/lib/google/cloud/dialogflow/cx/v3/intents/rest/client.rb +46 -8
  38. data/lib/google/cloud/dialogflow/cx/v3/intents/rest/operations.rb +50 -38
  39. data/lib/google/cloud/dialogflow/cx/v3/intents/rest/service_stub.rb +70 -44
  40. data/lib/google/cloud/dialogflow/cx/v3/pages/client.rb +36 -6
  41. data/lib/google/cloud/dialogflow/cx/v3/pages/rest/client.rb +36 -6
  42. data/lib/google/cloud/dialogflow/cx/v3/pages/rest/service_stub.rb +54 -32
  43. data/lib/google/cloud/dialogflow/cx/v3/security_settings_service/client.rb +36 -6
  44. data/lib/google/cloud/dialogflow/cx/v3/security_settings_service/rest/client.rb +36 -6
  45. data/lib/google/cloud/dialogflow/cx/v3/security_settings_service/rest/service_stub.rb +54 -32
  46. data/lib/google/cloud/dialogflow/cx/v3/session_entity_types/client.rb +36 -6
  47. data/lib/google/cloud/dialogflow/cx/v3/session_entity_types/rest/client.rb +36 -6
  48. data/lib/google/cloud/dialogflow/cx/v3/session_entity_types/rest/service_stub.rb +54 -32
  49. data/lib/google/cloud/dialogflow/cx/v3/sessions/client.rb +35 -7
  50. data/lib/google/cloud/dialogflow/cx/v3/sessions/rest/client.rb +35 -5
  51. data/lib/google/cloud/dialogflow/cx/v3/sessions/rest/service_stub.rb +47 -26
  52. data/lib/google/cloud/dialogflow/cx/v3/test_cases/client.rb +45 -13
  53. data/lib/google/cloud/dialogflow/cx/v3/test_cases/operations.rb +19 -15
  54. data/lib/google/cloud/dialogflow/cx/v3/test_cases/rest/client.rb +45 -13
  55. data/lib/google/cloud/dialogflow/cx/v3/test_cases/rest/operations.rb +50 -38
  56. data/lib/google/cloud/dialogflow/cx/v3/test_cases/rest/service_stub.rb +110 -74
  57. data/lib/google/cloud/dialogflow/cx/v3/transition_route_groups/client.rb +36 -6
  58. data/lib/google/cloud/dialogflow/cx/v3/transition_route_groups/rest/client.rb +36 -6
  59. data/lib/google/cloud/dialogflow/cx/v3/transition_route_groups/rest/service_stub.rb +54 -32
  60. data/lib/google/cloud/dialogflow/cx/v3/version.rb +1 -1
  61. data/lib/google/cloud/dialogflow/cx/v3/versions/client.rb +38 -8
  62. data/lib/google/cloud/dialogflow/cx/v3/versions/operations.rb +19 -15
  63. data/lib/google/cloud/dialogflow/cx/v3/versions/rest/client.rb +38 -8
  64. data/lib/google/cloud/dialogflow/cx/v3/versions/rest/operations.rb +50 -38
  65. data/lib/google/cloud/dialogflow/cx/v3/versions/rest/service_stub.rb +70 -44
  66. data/lib/google/cloud/dialogflow/cx/v3/webhooks/client.rb +36 -6
  67. data/lib/google/cloud/dialogflow/cx/v3/webhooks/rest/client.rb +36 -6
  68. data/lib/google/cloud/dialogflow/cx/v3/webhooks/rest/service_stub.rb +54 -32
  69. data/proto_docs/google/api/client.rb +19 -0
  70. data/proto_docs/google/cloud/dialogflow/cx/v3/agent.rb +12 -0
  71. data/proto_docs/google/cloud/dialogflow/cx/v3/entity_type.rb +12 -0
  72. data/proto_docs/google/cloud/dialogflow/cx/v3/experiment.rb +4 -0
  73. data/proto_docs/google/cloud/dialogflow/cx/v3/flow.rb +8 -0
  74. data/proto_docs/google/cloud/dialogflow/cx/v3/fulfillment.rb +4 -0
  75. data/proto_docs/google/cloud/dialogflow/cx/v3/intent.rb +12 -0
  76. data/proto_docs/google/cloud/dialogflow/cx/v3/page.rb +12 -0
  77. data/proto_docs/google/cloud/dialogflow/cx/v3/response_message.rb +28 -0
  78. data/proto_docs/google/cloud/dialogflow/cx/v3/security_settings.rb +4 -0
  79. data/proto_docs/google/cloud/dialogflow/cx/v3/session.rb +32 -0
  80. data/proto_docs/google/cloud/dialogflow/cx/v3/test_case.rb +22 -0
  81. data/proto_docs/google/cloud/dialogflow/cx/v3/webhook.rb +18 -0
  82. data/proto_docs/google/longrunning/operations.rb +23 -14
  83. data/proto_docs/google/protobuf/struct.rb +12 -0
  84. metadata +6 -9
@@ -31,7 +31,8 @@ module Google
31
31
  # including transcoding, making the REST call, and deserialing the response.
32
32
  #
33
33
  class ServiceStub
34
- def initialize endpoint:, endpoint_template:, universe_domain:, credentials:
34
+ # @private
35
+ def initialize endpoint:, endpoint_template:, universe_domain:, credentials:, logger:
35
36
  # These require statements are intentionally placed here to initialize
36
37
  # the REST modules only when it's required.
37
38
  require "gapic/rest"
@@ -41,7 +42,9 @@ module Google
41
42
  universe_domain: universe_domain,
42
43
  credentials: credentials,
43
44
  numeric_enums: true,
44
- raise_faraday_errors: false
45
+ service_name: self.class,
46
+ raise_faraday_errors: false,
47
+ logger: logger
45
48
  end
46
49
 
47
50
  ##
@@ -62,6 +65,15 @@ module Google
62
65
  @client_stub.endpoint
63
66
  end
64
67
 
68
+ ##
69
+ # The logger used for request/response debug logging.
70
+ #
71
+ # @return [Logger]
72
+ #
73
+ def logger stub: false
74
+ stub ? @client_stub.stub_logger : @client_stub.logger
75
+ end
76
+
65
77
  ##
66
78
  # Baseline implementation for the create_security_settings REST call
67
79
  #
@@ -88,16 +100,18 @@ module Google
88
100
 
89
101
  response = @client_stub.make_http_request(
90
102
  verb,
91
- uri: uri,
92
- body: body || "",
93
- params: query_string_params,
103
+ uri: uri,
104
+ body: body || "",
105
+ params: query_string_params,
106
+ method_name: "create_security_settings",
94
107
  options: options
95
108
  )
96
109
  operation = ::Gapic::Rest::TransportOperation.new response
97
110
  result = ::Google::Cloud::Dialogflow::CX::V3::SecuritySettings.decode_json response.body, ignore_unknown_fields: true
98
-
99
- yield result, operation if block_given?
100
- result
111
+ catch :response do
112
+ yield result, operation if block_given?
113
+ result
114
+ end
101
115
  end
102
116
 
103
117
  ##
@@ -126,16 +140,18 @@ module Google
126
140
 
127
141
  response = @client_stub.make_http_request(
128
142
  verb,
129
- uri: uri,
130
- body: body || "",
131
- params: query_string_params,
143
+ uri: uri,
144
+ body: body || "",
145
+ params: query_string_params,
146
+ method_name: "get_security_settings",
132
147
  options: options
133
148
  )
134
149
  operation = ::Gapic::Rest::TransportOperation.new response
135
150
  result = ::Google::Cloud::Dialogflow::CX::V3::SecuritySettings.decode_json response.body, ignore_unknown_fields: true
136
-
137
- yield result, operation if block_given?
138
- result
151
+ catch :response do
152
+ yield result, operation if block_given?
153
+ result
154
+ end
139
155
  end
140
156
 
141
157
  ##
@@ -164,16 +180,18 @@ module Google
164
180
 
165
181
  response = @client_stub.make_http_request(
166
182
  verb,
167
- uri: uri,
168
- body: body || "",
169
- params: query_string_params,
183
+ uri: uri,
184
+ body: body || "",
185
+ params: query_string_params,
186
+ method_name: "update_security_settings",
170
187
  options: options
171
188
  )
172
189
  operation = ::Gapic::Rest::TransportOperation.new response
173
190
  result = ::Google::Cloud::Dialogflow::CX::V3::SecuritySettings.decode_json response.body, ignore_unknown_fields: true
174
-
175
- yield result, operation if block_given?
176
- result
191
+ catch :response do
192
+ yield result, operation if block_given?
193
+ result
194
+ end
177
195
  end
178
196
 
179
197
  ##
@@ -202,16 +220,18 @@ module Google
202
220
 
203
221
  response = @client_stub.make_http_request(
204
222
  verb,
205
- uri: uri,
206
- body: body || "",
207
- params: query_string_params,
223
+ uri: uri,
224
+ body: body || "",
225
+ params: query_string_params,
226
+ method_name: "list_security_settings",
208
227
  options: options
209
228
  )
210
229
  operation = ::Gapic::Rest::TransportOperation.new response
211
230
  result = ::Google::Cloud::Dialogflow::CX::V3::ListSecuritySettingsResponse.decode_json response.body, ignore_unknown_fields: true
212
-
213
- yield result, operation if block_given?
214
- result
231
+ catch :response do
232
+ yield result, operation if block_given?
233
+ result
234
+ end
215
235
  end
216
236
 
217
237
  ##
@@ -240,16 +260,18 @@ module Google
240
260
 
241
261
  response = @client_stub.make_http_request(
242
262
  verb,
243
- uri: uri,
244
- body: body || "",
245
- params: query_string_params,
263
+ uri: uri,
264
+ body: body || "",
265
+ params: query_string_params,
266
+ method_name: "delete_security_settings",
246
267
  options: options
247
268
  )
248
269
  operation = ::Gapic::Rest::TransportOperation.new response
249
270
  result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
250
-
251
- yield result, operation if block_given?
252
- result
271
+ catch :response do
272
+ yield result, operation if block_given?
273
+ result
274
+ end
253
275
  end
254
276
 
255
277
  ##
@@ -165,14 +165,26 @@ module Google
165
165
  universe_domain: @config.universe_domain,
166
166
  channel_args: @config.channel_args,
167
167
  interceptors: @config.interceptors,
168
- channel_pool_config: @config.channel_pool
168
+ channel_pool_config: @config.channel_pool,
169
+ logger: @config.logger
169
170
  )
170
171
 
172
+ @session_entity_types_stub.stub_logger&.info do |entry|
173
+ entry.set_system_name
174
+ entry.set_service
175
+ entry.message = "Created client for #{entry.service}"
176
+ entry.set_credentials_fields credentials
177
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
178
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
179
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
180
+ end
181
+
171
182
  @location_client = Google::Cloud::Location::Locations::Client.new do |config|
172
183
  config.credentials = credentials
173
184
  config.quota_project = @quota_project_id
174
185
  config.endpoint = @session_entity_types_stub.endpoint
175
186
  config.universe_domain = @session_entity_types_stub.universe_domain
187
+ config.logger = @session_entity_types_stub.logger if config.respond_to? :logger=
176
188
  end
177
189
  end
178
190
 
@@ -183,6 +195,15 @@ module Google
183
195
  #
184
196
  attr_reader :location_client
185
197
 
198
+ ##
199
+ # The logger used for request/response debug logging.
200
+ #
201
+ # @return [Logger]
202
+ #
203
+ def logger
204
+ @session_entity_types_stub.logger
205
+ end
206
+
186
207
  # Service calls
187
208
 
188
209
  ##
@@ -281,7 +302,7 @@ module Google
281
302
  @session_entity_types_stub.call_rpc :list_session_entity_types, request, options: options do |response, operation|
282
303
  response = ::Gapic::PagedEnumerable.new @session_entity_types_stub, :list_session_entity_types, request, response, operation, options
283
304
  yield response, operation if block_given?
284
- return response
305
+ throw :response, response
285
306
  end
286
307
  rescue ::GRPC::BadStatus => e
287
308
  raise ::Google::Cloud::Error.from_error(e)
@@ -373,7 +394,6 @@ module Google
373
394
 
374
395
  @session_entity_types_stub.call_rpc :get_session_entity_type, request, options: options do |response, operation|
375
396
  yield response, operation if block_given?
376
- return response
377
397
  end
378
398
  rescue ::GRPC::BadStatus => e
379
399
  raise ::Google::Cloud::Error.from_error(e)
@@ -467,7 +487,6 @@ module Google
467
487
 
468
488
  @session_entity_types_stub.call_rpc :create_session_entity_type, request, options: options do |response, operation|
469
489
  yield response, operation if block_given?
470
- return response
471
490
  end
472
491
  rescue ::GRPC::BadStatus => e
473
492
  raise ::Google::Cloud::Error.from_error(e)
@@ -561,7 +580,6 @@ module Google
561
580
 
562
581
  @session_entity_types_stub.call_rpc :update_session_entity_type, request, options: options do |response, operation|
563
582
  yield response, operation if block_given?
564
- return response
565
583
  end
566
584
  rescue ::GRPC::BadStatus => e
567
585
  raise ::Google::Cloud::Error.from_error(e)
@@ -653,7 +671,6 @@ module Google
653
671
 
654
672
  @session_entity_types_stub.call_rpc :delete_session_entity_type, request, options: options do |response, operation|
655
673
  yield response, operation if block_given?
656
- return response
657
674
  end
658
675
  rescue ::GRPC::BadStatus => e
659
676
  raise ::Google::Cloud::Error.from_error(e)
@@ -703,6 +720,13 @@ module Google
703
720
  # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
704
721
  # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
705
722
  # * (`nil`) indicating no credentials
723
+ #
724
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
725
+ # external source for authentication to Google Cloud, you must validate it before
726
+ # providing it to a Google API client library. Providing an unvalidated credential
727
+ # configuration to Google APIs can compromise the security of your systems and data.
728
+ # For more information, refer to [Validate credential configurations from external
729
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
706
730
  # @return [::Object]
707
731
  # @!attribute [rw] scope
708
732
  # The OAuth scopes
@@ -742,6 +766,11 @@ module Google
742
766
  # default endpoint URL. The default value of nil uses the environment
743
767
  # universe (usually the default "googleapis.com" universe).
744
768
  # @return [::String,nil]
769
+ # @!attribute [rw] logger
770
+ # A custom logger to use for request/response debug logging, or the value
771
+ # `:default` (the default) to construct a default logger, or `nil` to
772
+ # explicitly disable logging.
773
+ # @return [::Logger,:default,nil]
745
774
  #
746
775
  class Configuration
747
776
  extend ::Gapic::Config
@@ -766,6 +795,7 @@ module Google
766
795
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
767
796
  config_attr :quota_project, nil, ::String, nil
768
797
  config_attr :universe_domain, nil, ::String, nil
798
+ config_attr :logger, :default, ::Logger, nil, :default
769
799
 
770
800
  # @private
771
801
  def initialize parent_config = nil
@@ -158,15 +158,27 @@ module Google
158
158
  endpoint: @config.endpoint,
159
159
  endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
160
160
  universe_domain: @config.universe_domain,
161
- credentials: credentials
161
+ credentials: credentials,
162
+ logger: @config.logger
162
163
  )
163
164
 
165
+ @session_entity_types_stub.logger(stub: true)&.info do |entry|
166
+ entry.set_system_name
167
+ entry.set_service
168
+ entry.message = "Created client for #{entry.service}"
169
+ entry.set_credentials_fields credentials
170
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
171
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
172
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
173
+ end
174
+
164
175
  @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
165
176
  config.credentials = credentials
166
177
  config.quota_project = @quota_project_id
167
178
  config.endpoint = @session_entity_types_stub.endpoint
168
179
  config.universe_domain = @session_entity_types_stub.universe_domain
169
180
  config.bindings_override = @config.bindings_override
181
+ config.logger = @session_entity_types_stub.logger if config.respond_to? :logger=
170
182
  end
171
183
  end
172
184
 
@@ -177,6 +189,15 @@ module Google
177
189
  #
178
190
  attr_reader :location_client
179
191
 
192
+ ##
193
+ # The logger used for request/response debug logging.
194
+ #
195
+ # @return [Logger]
196
+ #
197
+ def logger
198
+ @session_entity_types_stub.logger
199
+ end
200
+
180
201
  # Service calls
181
202
 
182
203
  ##
@@ -268,7 +289,7 @@ module Google
268
289
  @session_entity_types_stub.list_session_entity_types request, options do |result, operation|
269
290
  result = ::Gapic::Rest::PagedEnumerable.new @session_entity_types_stub, :list_session_entity_types, "session_entity_types", request, result, options
270
291
  yield result, operation if block_given?
271
- return result
292
+ throw :response, result
272
293
  end
273
294
  rescue ::Gapic::Rest::Error => e
274
295
  raise ::Google::Cloud::Error.from_error(e)
@@ -353,7 +374,6 @@ module Google
353
374
 
354
375
  @session_entity_types_stub.get_session_entity_type request, options do |result, operation|
355
376
  yield result, operation if block_given?
356
- return result
357
377
  end
358
378
  rescue ::Gapic::Rest::Error => e
359
379
  raise ::Google::Cloud::Error.from_error(e)
@@ -440,7 +460,6 @@ module Google
440
460
 
441
461
  @session_entity_types_stub.create_session_entity_type request, options do |result, operation|
442
462
  yield result, operation if block_given?
443
- return result
444
463
  end
445
464
  rescue ::Gapic::Rest::Error => e
446
465
  raise ::Google::Cloud::Error.from_error(e)
@@ -527,7 +546,6 @@ module Google
527
546
 
528
547
  @session_entity_types_stub.update_session_entity_type request, options do |result, operation|
529
548
  yield result, operation if block_given?
530
- return result
531
549
  end
532
550
  rescue ::Gapic::Rest::Error => e
533
551
  raise ::Google::Cloud::Error.from_error(e)
@@ -612,7 +630,6 @@ module Google
612
630
 
613
631
  @session_entity_types_stub.delete_session_entity_type request, options do |result, operation|
614
632
  yield result, operation if block_given?
615
- return result
616
633
  end
617
634
  rescue ::Gapic::Rest::Error => e
618
635
  raise ::Google::Cloud::Error.from_error(e)
@@ -660,6 +677,13 @@ module Google
660
677
  # * (`Signet::OAuth2::Client`) A signet oauth2 client object
661
678
  # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
662
679
  # * (`nil`) indicating no credentials
680
+ #
681
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
682
+ # external source for authentication to Google Cloud, you must validate it before
683
+ # providing it to a Google API client library. Providing an unvalidated credential
684
+ # configuration to Google APIs can compromise the security of your systems and data.
685
+ # For more information, refer to [Validate credential configurations from external
686
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
663
687
  # @return [::Object]
664
688
  # @!attribute [rw] scope
665
689
  # The OAuth scopes
@@ -692,6 +716,11 @@ module Google
692
716
  # default endpoint URL. The default value of nil uses the environment
693
717
  # universe (usually the default "googleapis.com" universe).
694
718
  # @return [::String,nil]
719
+ # @!attribute [rw] logger
720
+ # A custom logger to use for request/response debug logging, or the value
721
+ # `:default` (the default) to construct a default logger, or `nil` to
722
+ # explicitly disable logging.
723
+ # @return [::Logger,:default,nil]
695
724
  #
696
725
  class Configuration
697
726
  extend ::Gapic::Config
@@ -720,6 +749,7 @@ module Google
720
749
  # by the host service.
721
750
  # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
722
751
  config_attr :bindings_override, {}, ::Hash, nil
752
+ config_attr :logger, :default, ::Logger, nil, :default
723
753
 
724
754
  # @private
725
755
  def initialize parent_config = nil
@@ -31,7 +31,8 @@ module Google
31
31
  # including transcoding, making the REST call, and deserialing the response.
32
32
  #
33
33
  class ServiceStub
34
- def initialize endpoint:, endpoint_template:, universe_domain:, credentials:
34
+ # @private
35
+ def initialize endpoint:, endpoint_template:, universe_domain:, credentials:, logger:
35
36
  # These require statements are intentionally placed here to initialize
36
37
  # the REST modules only when it's required.
37
38
  require "gapic/rest"
@@ -41,7 +42,9 @@ module Google
41
42
  universe_domain: universe_domain,
42
43
  credentials: credentials,
43
44
  numeric_enums: true,
44
- raise_faraday_errors: false
45
+ service_name: self.class,
46
+ raise_faraday_errors: false,
47
+ logger: logger
45
48
  end
46
49
 
47
50
  ##
@@ -62,6 +65,15 @@ module Google
62
65
  @client_stub.endpoint
63
66
  end
64
67
 
68
+ ##
69
+ # The logger used for request/response debug logging.
70
+ #
71
+ # @return [Logger]
72
+ #
73
+ def logger stub: false
74
+ stub ? @client_stub.stub_logger : @client_stub.logger
75
+ end
76
+
65
77
  ##
66
78
  # Baseline implementation for the list_session_entity_types REST call
67
79
  #
@@ -88,16 +100,18 @@ module Google
88
100
 
89
101
  response = @client_stub.make_http_request(
90
102
  verb,
91
- uri: uri,
92
- body: body || "",
93
- params: query_string_params,
103
+ uri: uri,
104
+ body: body || "",
105
+ params: query_string_params,
106
+ method_name: "list_session_entity_types",
94
107
  options: options
95
108
  )
96
109
  operation = ::Gapic::Rest::TransportOperation.new response
97
110
  result = ::Google::Cloud::Dialogflow::CX::V3::ListSessionEntityTypesResponse.decode_json response.body, ignore_unknown_fields: true
98
-
99
- yield result, operation if block_given?
100
- result
111
+ catch :response do
112
+ yield result, operation if block_given?
113
+ result
114
+ end
101
115
  end
102
116
 
103
117
  ##
@@ -126,16 +140,18 @@ module Google
126
140
 
127
141
  response = @client_stub.make_http_request(
128
142
  verb,
129
- uri: uri,
130
- body: body || "",
131
- params: query_string_params,
143
+ uri: uri,
144
+ body: body || "",
145
+ params: query_string_params,
146
+ method_name: "get_session_entity_type",
132
147
  options: options
133
148
  )
134
149
  operation = ::Gapic::Rest::TransportOperation.new response
135
150
  result = ::Google::Cloud::Dialogflow::CX::V3::SessionEntityType.decode_json response.body, ignore_unknown_fields: true
136
-
137
- yield result, operation if block_given?
138
- result
151
+ catch :response do
152
+ yield result, operation if block_given?
153
+ result
154
+ end
139
155
  end
140
156
 
141
157
  ##
@@ -164,16 +180,18 @@ module Google
164
180
 
165
181
  response = @client_stub.make_http_request(
166
182
  verb,
167
- uri: uri,
168
- body: body || "",
169
- params: query_string_params,
183
+ uri: uri,
184
+ body: body || "",
185
+ params: query_string_params,
186
+ method_name: "create_session_entity_type",
170
187
  options: options
171
188
  )
172
189
  operation = ::Gapic::Rest::TransportOperation.new response
173
190
  result = ::Google::Cloud::Dialogflow::CX::V3::SessionEntityType.decode_json response.body, ignore_unknown_fields: true
174
-
175
- yield result, operation if block_given?
176
- result
191
+ catch :response do
192
+ yield result, operation if block_given?
193
+ result
194
+ end
177
195
  end
178
196
 
179
197
  ##
@@ -202,16 +220,18 @@ module Google
202
220
 
203
221
  response = @client_stub.make_http_request(
204
222
  verb,
205
- uri: uri,
206
- body: body || "",
207
- params: query_string_params,
223
+ uri: uri,
224
+ body: body || "",
225
+ params: query_string_params,
226
+ method_name: "update_session_entity_type",
208
227
  options: options
209
228
  )
210
229
  operation = ::Gapic::Rest::TransportOperation.new response
211
230
  result = ::Google::Cloud::Dialogflow::CX::V3::SessionEntityType.decode_json response.body, ignore_unknown_fields: true
212
-
213
- yield result, operation if block_given?
214
- result
231
+ catch :response do
232
+ yield result, operation if block_given?
233
+ result
234
+ end
215
235
  end
216
236
 
217
237
  ##
@@ -240,16 +260,18 @@ module Google
240
260
 
241
261
  response = @client_stub.make_http_request(
242
262
  verb,
243
- uri: uri,
244
- body: body || "",
245
- params: query_string_params,
263
+ uri: uri,
264
+ body: body || "",
265
+ params: query_string_params,
266
+ method_name: "delete_session_entity_type",
246
267
  options: options
247
268
  )
248
269
  operation = ::Gapic::Rest::TransportOperation.new response
249
270
  result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
250
-
251
- yield result, operation if block_given?
252
- result
271
+ catch :response do
272
+ yield result, operation if block_given?
273
+ result
274
+ end
253
275
  end
254
276
 
255
277
  ##
@@ -176,14 +176,26 @@ module Google
176
176
  universe_domain: @config.universe_domain,
177
177
  channel_args: @config.channel_args,
178
178
  interceptors: @config.interceptors,
179
- channel_pool_config: @config.channel_pool
179
+ channel_pool_config: @config.channel_pool,
180
+ logger: @config.logger
180
181
  )
181
182
 
183
+ @sessions_stub.stub_logger&.info do |entry|
184
+ entry.set_system_name
185
+ entry.set_service
186
+ entry.message = "Created client for #{entry.service}"
187
+ entry.set_credentials_fields credentials
188
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
189
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
190
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
191
+ end
192
+
182
193
  @location_client = Google::Cloud::Location::Locations::Client.new do |config|
183
194
  config.credentials = credentials
184
195
  config.quota_project = @quota_project_id
185
196
  config.endpoint = @sessions_stub.endpoint
186
197
  config.universe_domain = @sessions_stub.universe_domain
198
+ config.logger = @sessions_stub.logger if config.respond_to? :logger=
187
199
  end
188
200
  end
189
201
 
@@ -194,6 +206,15 @@ module Google
194
206
  #
195
207
  attr_reader :location_client
196
208
 
209
+ ##
210
+ # The logger used for request/response debug logging.
211
+ #
212
+ # @return [Logger]
213
+ #
214
+ def logger
215
+ @sessions_stub.logger
216
+ end
217
+
197
218
  # Service calls
198
219
 
199
220
  ##
@@ -305,7 +326,6 @@ module Google
305
326
 
306
327
  @sessions_stub.call_rpc :detect_intent, request, options: options do |response, operation|
307
328
  yield response, operation if block_given?
308
- return response
309
329
  end
310
330
  rescue ::GRPC::BadStatus => e
311
331
  raise ::Google::Cloud::Error.from_error(e)
@@ -420,7 +440,6 @@ module Google
420
440
 
421
441
  @sessions_stub.call_rpc :server_streaming_detect_intent, request, options: options do |response, operation|
422
442
  yield response, operation if block_given?
423
- return response
424
443
  end
425
444
  rescue ::GRPC::BadStatus => e
426
445
  raise ::Google::Cloud::Error.from_error(e)
@@ -505,7 +524,6 @@ module Google
505
524
 
506
525
  @sessions_stub.call_rpc :streaming_detect_intent, request, options: options do |response, operation|
507
526
  yield response, operation if block_given?
508
- return response
509
527
  end
510
528
  rescue ::GRPC::BadStatus => e
511
529
  raise ::Google::Cloud::Error.from_error(e)
@@ -610,7 +628,6 @@ module Google
610
628
 
611
629
  @sessions_stub.call_rpc :match_intent, request, options: options do |response, operation|
612
630
  yield response, operation if block_given?
613
- return response
614
631
  end
615
632
  rescue ::GRPC::BadStatus => e
616
633
  raise ::Google::Cloud::Error.from_error(e)
@@ -707,7 +724,6 @@ module Google
707
724
 
708
725
  @sessions_stub.call_rpc :fulfill_intent, request, options: options do |response, operation|
709
726
  yield response, operation if block_given?
710
- return response
711
727
  end
712
728
  rescue ::GRPC::BadStatus => e
713
729
  raise ::Google::Cloud::Error.from_error(e)
@@ -802,7 +818,6 @@ module Google
802
818
 
803
819
  @sessions_stub.call_rpc :submit_answer_feedback, request, options: options do |response, operation|
804
820
  yield response, operation if block_given?
805
- return response
806
821
  end
807
822
  rescue ::GRPC::BadStatus => e
808
823
  raise ::Google::Cloud::Error.from_error(e)
@@ -852,6 +867,13 @@ module Google
852
867
  # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
853
868
  # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
854
869
  # * (`nil`) indicating no credentials
870
+ #
871
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
872
+ # external source for authentication to Google Cloud, you must validate it before
873
+ # providing it to a Google API client library. Providing an unvalidated credential
874
+ # configuration to Google APIs can compromise the security of your systems and data.
875
+ # For more information, refer to [Validate credential configurations from external
876
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
855
877
  # @return [::Object]
856
878
  # @!attribute [rw] scope
857
879
  # The OAuth scopes
@@ -891,6 +913,11 @@ module Google
891
913
  # default endpoint URL. The default value of nil uses the environment
892
914
  # universe (usually the default "googleapis.com" universe).
893
915
  # @return [::String,nil]
916
+ # @!attribute [rw] logger
917
+ # A custom logger to use for request/response debug logging, or the value
918
+ # `:default` (the default) to construct a default logger, or `nil` to
919
+ # explicitly disable logging.
920
+ # @return [::Logger,:default,nil]
894
921
  #
895
922
  class Configuration
896
923
  extend ::Gapic::Config
@@ -915,6 +942,7 @@ module Google
915
942
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
916
943
  config_attr :quota_project, nil, ::String, nil
917
944
  config_attr :universe_domain, nil, ::String, nil
945
+ config_attr :logger, :default, ::Logger, nil, :default
918
946
 
919
947
  # @private
920
948
  def initialize parent_config = nil