google-cloud-dialogflow 0.1.0 → 0.2.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: 229a61fb2d5d02dd466058f0e1b90b9a84619f933fd9c0a0432c7cf4c3c48813
4
- data.tar.gz: 275e5947988d587ffe13cda4443e53ced1413ec28af0cae376eb872ca5305eae
3
+ metadata.gz: 4eec775b6e0a5bf58391574cf0cc4360c723d8e05c38be3bf8a3fbbbecd94ae4
4
+ data.tar.gz: 7a495e93f68e6ecd8eea5a1b42f09040f6b9490760dd4ecbc07da8da99f8fac7
5
5
  SHA512:
6
- metadata.gz: c204361b8718a32cb8dc3fdfdcea688b30a1bf566dee881ee8b3a770558b15c99f0ccbbcd8496adb76b13e8cd323381cee5da9d4f47095ba49915aed6d82b0ae
7
- data.tar.gz: 5080029d8710ec1bd5894c80af56f9c5cf38efc57156970e44e847b5edecf9b38dd8c47237c859e2d0e999bb32990f721c9ba36195b94b541e23072aea3fc372
6
+ metadata.gz: 8e550945990483bdf2c052c0c0a35dd0259ba28a44d5780f72a78d243adbd78eaf2b1951b2dc9ed4b863e2f7a5d41f080b3767e69c11d853cd1c86617d5a2dd4
7
+ data.tar.gz: 51d57428a3b290cc4df523ea4a81cfe36dde9d6a365c9ebc2e4ec5ede4cf94c2def8f7c5770a9aeedf8eb35d8e03e1b81f291a088d41d82633841beb2c213816
data/.yardopts CHANGED
@@ -2,6 +2,7 @@
2
2
  --title=Dialogflow API
3
3
  --exclude _pb\.rb$
4
4
  --markup markdown
5
+ --markup-provider redcarpet
5
6
 
6
7
  ./lib/**/*.rb
7
8
  -
data/README.md CHANGED
@@ -21,7 +21,7 @@ $ gem install google-cloud-dialogflow
21
21
  ```
22
22
 
23
23
  ### Next Steps
24
- - Read the [Client Library Documentation][https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-dialogflow/latest/google/cloud/dialogflow] for Dialogflow API
24
+ - Read the [Client Library Documentation][] for Dialogflow API
25
25
  to see other available methods on the client.
26
26
  - Read the [Dialogflow API Product documentation][Product Documentation]
27
27
  to learn more about the product and see How-to Guides.
@@ -30,3 +30,40 @@ $ gem install google-cloud-dialogflow
30
30
 
31
31
  [Client Library Documentation]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-dialogflow/latest/google/cloud/dialogflow/v2
32
32
  [Product Documentation]: https://cloud.google.com/dialogflow
33
+
34
+ ## Enabling Logging
35
+
36
+ To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
37
+ The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
38
+ or a [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
39
+ that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
40
+ and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
41
+
42
+ Configuring a Ruby stdlib logger:
43
+
44
+ ```ruby
45
+ require "logger"
46
+
47
+ module MyLogger
48
+ LOGGER = Logger.new $stderr, level: Logger::WARN
49
+ def logger
50
+ LOGGER
51
+ end
52
+ end
53
+
54
+ # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
55
+ module GRPC
56
+ extend MyLogger
57
+ end
58
+ ```
59
+
60
+ ## Supported Ruby Versions
61
+
62
+ This library is supported on Ruby 2.3+.
63
+
64
+ Google provides official support for Ruby versions that are actively supported
65
+ by Ruby Core—that is, Ruby versions that are either in normal maintenance or
66
+ in security maintenance, and not end of life. Currently, this means Ruby 2.3
67
+ and later. Older versions of Ruby _may_ still work, but are unsupported and not
68
+ recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details
69
+ about the Ruby support schedule.
@@ -33,7 +33,7 @@ module Google
33
33
  #
34
34
  # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
35
35
  # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
36
- # 3. [Enable the Dialogflow API.](https://console.cloud.google.com/apis/api/dialogflow)
36
+ # 3. [Enable the Dialogflow API.](https://console.cloud.google.com/apis/library/dialogflow.googleapis.com)
37
37
  # 4. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
38
38
  #
39
39
  # ### Next Steps
@@ -44,6 +44,31 @@ module Google
44
44
  #
45
45
  # [Product Documentation]: https://cloud.google.com/dialogflow
46
46
  #
47
+ # ## Enabling Logging
48
+ #
49
+ # To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
50
+ # The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
51
+ # or a [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
52
+ # that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
53
+ # and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
54
+ #
55
+ # Configuring a Ruby stdlib logger:
56
+ #
57
+ # ```ruby
58
+ # require "logger"
59
+ #
60
+ # module MyLogger
61
+ # LOGGER = Logger.new $stderr, level: Logger::WARN
62
+ # def logger
63
+ # LOGGER
64
+ # end
65
+ # end
66
+ #
67
+ # # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
68
+ # module GRPC
69
+ # extend MyLogger
70
+ # end
71
+ # ```
47
72
  #
48
73
  module Dialogflow
49
74
  # rubocop:enable LineLength
@@ -112,6 +137,11 @@ module Google
112
137
  # or the specified config is missing data points.
113
138
  # @param timeout [Numeric]
114
139
  # The default timeout, in seconds, for calls made through this client.
140
+ # @param metadata [Hash]
141
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
142
+ # @param exception_transformer [Proc]
143
+ # An optional proc that intercepts any exceptions raised during an API call to inject
144
+ # custom error handling.
115
145
  def self.new(*args, version: :v2, **kwargs)
116
146
  unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
117
147
  raise "The version: #{version} is not available. The available versions " \
@@ -175,6 +205,11 @@ module Google
175
205
  # or the specified config is missing data points.
176
206
  # @param timeout [Numeric]
177
207
  # The default timeout, in seconds, for calls made through this client.
208
+ # @param metadata [Hash]
209
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
210
+ # @param exception_transformer [Proc]
211
+ # An optional proc that intercepts any exceptions raised during an API call to inject
212
+ # custom error handling.
178
213
  def self.new(*args, version: :v2, **kwargs)
179
214
  unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
180
215
  raise "The version: #{version} is not available. The available versions " \
@@ -248,6 +283,11 @@ module Google
248
283
  # or the specified config is missing data points.
249
284
  # @param timeout [Numeric]
250
285
  # The default timeout, in seconds, for calls made through this client.
286
+ # @param metadata [Hash]
287
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
288
+ # @param exception_transformer [Proc]
289
+ # An optional proc that intercepts any exceptions raised during an API call to inject
290
+ # custom error handling.
251
291
  def self.new(*args, version: :v2, **kwargs)
252
292
  unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
253
293
  raise "The version: #{version} is not available. The available versions " \
@@ -325,6 +365,11 @@ module Google
325
365
  # or the specified config is missing data points.
326
366
  # @param timeout [Numeric]
327
367
  # The default timeout, in seconds, for calls made through this client.
368
+ # @param metadata [Hash]
369
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
370
+ # @param exception_transformer [Proc]
371
+ # An optional proc that intercepts any exceptions raised during an API call to inject
372
+ # custom error handling.
328
373
  def self.new(*args, version: :v2, **kwargs)
329
374
  unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
330
375
  raise "The version: #{version} is not available. The available versions " \
@@ -383,6 +428,11 @@ module Google
383
428
  # or the specified config is missing data points.
384
429
  # @param timeout [Numeric]
385
430
  # The default timeout, in seconds, for calls made through this client.
431
+ # @param metadata [Hash]
432
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
433
+ # @param exception_transformer [Proc]
434
+ # An optional proc that intercepts any exceptions raised during an API call to inject
435
+ # custom error handling.
386
436
  def self.new(*args, version: :v2, **kwargs)
387
437
  unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
388
438
  raise "The version: #{version} is not available. The available versions " \
@@ -433,6 +483,11 @@ module Google
433
483
  # or the specified config is missing data points.
434
484
  # @param timeout [Numeric]
435
485
  # The default timeout, in seconds, for calls made through this client.
486
+ # @param metadata [Hash]
487
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
488
+ # @param exception_transformer [Proc]
489
+ # An optional proc that intercepts any exceptions raised during an API call to inject
490
+ # custom error handling.
436
491
  def self.new(*args, version: :v2, **kwargs)
437
492
  unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
438
493
  raise "The version: #{version} is not available. The available versions " \
@@ -25,35 +25,60 @@ require "google/cloud/dialogflow/v2/webhook_pb"
25
25
 
26
26
  module Google
27
27
  module Cloud
28
- # rubocop:disable LineLength
29
-
30
- ##
31
- # # Ruby Client for Dialogflow API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
32
- #
33
- # [Dialogflow API][Product Documentation]:
34
- # An end-to-end development suite for conversational interfaces (e.g.,
35
- # chatbots, voice-powered apps and devices).
36
- # - [Product Documentation][]
37
- #
38
- # ## Quick Start
39
- # In order to use this library, you first need to go through the following
40
- # steps:
41
- #
42
- # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
43
- # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
44
- # 3. [Enable the Dialogflow API.](https://console.cloud.google.com/apis/api/dialogflow)
45
- # 4. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
46
- #
47
- # ### Next Steps
48
- # - Read the [Dialogflow API Product documentation][Product Documentation]
49
- # to learn more about the product and see How-to Guides.
50
- # - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
51
- # to see the full list of Cloud APIs that we cover.
52
- #
53
- # [Product Documentation]: https://cloud.google.com/dialogflow
54
- #
55
- #
56
28
  module Dialogflow
29
+ # rubocop:disable LineLength
30
+
31
+ ##
32
+ # # Ruby Client for Dialogflow API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
33
+ #
34
+ # [Dialogflow API][Product Documentation]:
35
+ # An end-to-end development suite for conversational interfaces (e.g.,
36
+ # chatbots, voice-powered apps and devices).
37
+ # - [Product Documentation][]
38
+ #
39
+ # ## Quick Start
40
+ # In order to use this library, you first need to go through the following
41
+ # steps:
42
+ #
43
+ # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
44
+ # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
45
+ # 3. [Enable the Dialogflow API.](https://console.cloud.google.com/apis/library/dialogflow.googleapis.com)
46
+ # 4. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
47
+ #
48
+ # ### Next Steps
49
+ # - Read the [Dialogflow API Product documentation][Product Documentation]
50
+ # to learn more about the product and see How-to Guides.
51
+ # - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
52
+ # to see the full list of Cloud APIs that we cover.
53
+ #
54
+ # [Product Documentation]: https://cloud.google.com/dialogflow
55
+ #
56
+ # ## Enabling Logging
57
+ #
58
+ # To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
59
+ # The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
60
+ # or a [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
61
+ # that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
62
+ # and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
63
+ #
64
+ # Configuring a Ruby stdlib logger:
65
+ #
66
+ # ```ruby
67
+ # require "logger"
68
+ #
69
+ # module MyLogger
70
+ # LOGGER = Logger.new $stderr, level: Logger::WARN
71
+ # def logger
72
+ # LOGGER
73
+ # end
74
+ # end
75
+ #
76
+ # # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
77
+ # module GRPC
78
+ # extend MyLogger
79
+ # end
80
+ # ```
81
+ #
57
82
  module V2
58
83
  # rubocop:enable LineLength
59
84
 
@@ -109,11 +134,18 @@ module Google
109
134
  # or the specified config is missing data points.
110
135
  # @param timeout [Numeric]
111
136
  # The default timeout, in seconds, for calls made through this client.
137
+ # @param metadata [Hash]
138
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
139
+ # @param exception_transformer [Proc]
140
+ # An optional proc that intercepts any exceptions raised during an API call to inject
141
+ # custom error handling.
112
142
  def self.new \
113
143
  credentials: nil,
114
144
  scopes: nil,
115
145
  client_config: nil,
116
146
  timeout: nil,
147
+ metadata: nil,
148
+ exception_transformer: nil,
117
149
  lib_name: nil,
118
150
  lib_version: nil
119
151
  kwargs = {
@@ -121,6 +153,8 @@ module Google
121
153
  scopes: scopes,
122
154
  client_config: client_config,
123
155
  timeout: timeout,
156
+ metadata: metadata,
157
+ exception_transformer: exception_transformer,
124
158
  lib_name: lib_name,
125
159
  lib_version: lib_version
126
160
  }.select { |_, v| v != nil }
@@ -172,11 +206,18 @@ module Google
172
206
  # or the specified config is missing data points.
173
207
  # @param timeout [Numeric]
174
208
  # The default timeout, in seconds, for calls made through this client.
209
+ # @param metadata [Hash]
210
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
211
+ # @param exception_transformer [Proc]
212
+ # An optional proc that intercepts any exceptions raised during an API call to inject
213
+ # custom error handling.
175
214
  def self.new \
176
215
  credentials: nil,
177
216
  scopes: nil,
178
217
  client_config: nil,
179
218
  timeout: nil,
219
+ metadata: nil,
220
+ exception_transformer: nil,
180
221
  lib_name: nil,
181
222
  lib_version: nil
182
223
  kwargs = {
@@ -184,6 +225,8 @@ module Google
184
225
  scopes: scopes,
185
226
  client_config: client_config,
186
227
  timeout: timeout,
228
+ metadata: metadata,
229
+ exception_transformer: exception_transformer,
187
230
  lib_name: lib_name,
188
231
  lib_version: lib_version
189
232
  }.select { |_, v| v != nil }
@@ -245,11 +288,18 @@ module Google
245
288
  # or the specified config is missing data points.
246
289
  # @param timeout [Numeric]
247
290
  # The default timeout, in seconds, for calls made through this client.
291
+ # @param metadata [Hash]
292
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
293
+ # @param exception_transformer [Proc]
294
+ # An optional proc that intercepts any exceptions raised during an API call to inject
295
+ # custom error handling.
248
296
  def self.new \
249
297
  credentials: nil,
250
298
  scopes: nil,
251
299
  client_config: nil,
252
300
  timeout: nil,
301
+ metadata: nil,
302
+ exception_transformer: nil,
253
303
  lib_name: nil,
254
304
  lib_version: nil
255
305
  kwargs = {
@@ -257,6 +307,8 @@ module Google
257
307
  scopes: scopes,
258
308
  client_config: client_config,
259
309
  timeout: timeout,
310
+ metadata: metadata,
311
+ exception_transformer: exception_transformer,
260
312
  lib_name: lib_name,
261
313
  lib_version: lib_version
262
314
  }.select { |_, v| v != nil }
@@ -322,11 +374,18 @@ module Google
322
374
  # or the specified config is missing data points.
323
375
  # @param timeout [Numeric]
324
376
  # The default timeout, in seconds, for calls made through this client.
377
+ # @param metadata [Hash]
378
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
379
+ # @param exception_transformer [Proc]
380
+ # An optional proc that intercepts any exceptions raised during an API call to inject
381
+ # custom error handling.
325
382
  def self.new \
326
383
  credentials: nil,
327
384
  scopes: nil,
328
385
  client_config: nil,
329
386
  timeout: nil,
387
+ metadata: nil,
388
+ exception_transformer: nil,
330
389
  lib_name: nil,
331
390
  lib_version: nil
332
391
  kwargs = {
@@ -334,6 +393,8 @@ module Google
334
393
  scopes: scopes,
335
394
  client_config: client_config,
336
395
  timeout: timeout,
396
+ metadata: metadata,
397
+ exception_transformer: exception_transformer,
337
398
  lib_name: lib_name,
338
399
  lib_version: lib_version
339
400
  }.select { |_, v| v != nil }
@@ -380,11 +441,18 @@ module Google
380
441
  # or the specified config is missing data points.
381
442
  # @param timeout [Numeric]
382
443
  # The default timeout, in seconds, for calls made through this client.
444
+ # @param metadata [Hash]
445
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
446
+ # @param exception_transformer [Proc]
447
+ # An optional proc that intercepts any exceptions raised during an API call to inject
448
+ # custom error handling.
383
449
  def self.new \
384
450
  credentials: nil,
385
451
  scopes: nil,
386
452
  client_config: nil,
387
453
  timeout: nil,
454
+ metadata: nil,
455
+ exception_transformer: nil,
388
456
  lib_name: nil,
389
457
  lib_version: nil
390
458
  kwargs = {
@@ -392,6 +460,8 @@ module Google
392
460
  scopes: scopes,
393
461
  client_config: client_config,
394
462
  timeout: timeout,
463
+ metadata: metadata,
464
+ exception_transformer: exception_transformer,
395
465
  lib_name: lib_name,
396
466
  lib_version: lib_version
397
467
  }.select { |_, v| v != nil }
@@ -430,11 +500,18 @@ module Google
430
500
  # or the specified config is missing data points.
431
501
  # @param timeout [Numeric]
432
502
  # The default timeout, in seconds, for calls made through this client.
503
+ # @param metadata [Hash]
504
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
505
+ # @param exception_transformer [Proc]
506
+ # An optional proc that intercepts any exceptions raised during an API call to inject
507
+ # custom error handling.
433
508
  def self.new \
434
509
  credentials: nil,
435
510
  scopes: nil,
436
511
  client_config: nil,
437
512
  timeout: nil,
513
+ metadata: nil,
514
+ exception_transformer: nil,
438
515
  lib_name: nil,
439
516
  lib_version: nil
440
517
  kwargs = {
@@ -442,6 +519,8 @@ module Google
442
519
  scopes: scopes,
443
520
  client_config: client_config,
444
521
  timeout: timeout,
522
+ metadata: metadata,
523
+ exception_transformer: exception_transformer,
445
524
  lib_name: lib_name,
446
525
  lib_version: lib_version
447
526
  }.select { |_, v| v != nil }
@@ -27,7 +27,7 @@ require "google/gax/operation"
27
27
  require "google/longrunning/operations_client"
28
28
 
29
29
  require "google/cloud/dialogflow/v2/agent_pb"
30
- require "google/cloud/dialogflow/credentials"
30
+ require "google/cloud/dialogflow/v2/credentials"
31
31
 
32
32
  module Google
33
33
  module Cloud
@@ -70,6 +70,9 @@ module Google
70
70
  # The default port of the service.
71
71
  DEFAULT_SERVICE_PORT = 443
72
72
 
73
+ # The default set of gRPC interceptors.
74
+ GRPC_INTERCEPTORS = []
75
+
73
76
  DEFAULT_TIMEOUT = 30
74
77
 
75
78
  PAGE_DESCRIPTORS = {
@@ -87,8 +90,10 @@ module Google
87
90
  "https://www.googleapis.com/auth/cloud-platform"
88
91
  ].freeze
89
92
 
93
+ # @private
90
94
  class OperationsClient < Google::Longrunning::OperationsClient
91
95
  self::SERVICE_ADDRESS = AgentsClient::SERVICE_ADDRESS
96
+ self::GRPC_INTERCEPTORS = AgentsClient::GRPC_INTERCEPTORS
92
97
  end
93
98
 
94
99
  PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
@@ -130,11 +135,18 @@ module Google
130
135
  # or the specified config is missing data points.
131
136
  # @param timeout [Numeric]
132
137
  # The default timeout, in seconds, for calls made through this client.
138
+ # @param metadata [Hash]
139
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
140
+ # @param exception_transformer [Proc]
141
+ # An optional proc that intercepts any exceptions raised during an API call to inject
142
+ # custom error handling.
133
143
  def initialize \
134
144
  credentials: nil,
135
145
  scopes: ALL_SCOPES,
136
146
  client_config: {},
137
147
  timeout: DEFAULT_TIMEOUT,
148
+ metadata: nil,
149
+ exception_transformer: nil,
138
150
  lib_name: nil,
139
151
  lib_version: ""
140
152
  # These require statements are intentionally placed here to initialize
@@ -143,7 +155,7 @@ module Google
143
155
  require "google/gax/grpc"
144
156
  require "google/cloud/dialogflow/v2/agent_services_pb"
145
157
 
146
- credentials ||= Google::Cloud::Dialogflow::Credentials.default
158
+ credentials ||= Google::Cloud::Dialogflow::V2::Credentials.default
147
159
 
148
160
  @operations_client = OperationsClient.new(
149
161
  credentials: credentials,
@@ -155,7 +167,7 @@ module Google
155
167
  )
156
168
 
157
169
  if credentials.is_a?(String) || credentials.is_a?(Hash)
158
- updater_proc = Google::Cloud::Dialogflow::Credentials.new(credentials).updater_proc
170
+ updater_proc = Google::Cloud::Dialogflow::V2::Credentials.new(credentials).updater_proc
159
171
  end
160
172
  if credentials.is_a?(GRPC::Core::Channel)
161
173
  channel = credentials
@@ -179,6 +191,7 @@ module Google
179
191
  google_api_client.freeze
180
192
 
181
193
  headers = { :"x-goog-api-client" => google_api_client }
194
+ headers.merge!(metadata) unless metadata.nil?
182
195
  client_config_file = Pathname.new(__dir__).join(
183
196
  "agents_client_config.json"
184
197
  )
@@ -191,13 +204,14 @@ module Google
191
204
  timeout,
192
205
  page_descriptors: PAGE_DESCRIPTORS,
193
206
  errors: Google::Gax::Grpc::API_ERRORS,
194
- kwargs: headers
207
+ metadata: headers
195
208
  )
196
209
  end
197
210
 
198
211
  # Allow overriding the service path/port in subclasses.
199
212
  service_path = self.class::SERVICE_ADDRESS
200
213
  port = self.class::DEFAULT_SERVICE_PORT
214
+ interceptors = self.class::GRPC_INTERCEPTORS
201
215
  @agents_stub = Google::Gax::Grpc.create_stub(
202
216
  service_path,
203
217
  port,
@@ -205,32 +219,39 @@ module Google
205
219
  channel: channel,
206
220
  updater_proc: updater_proc,
207
221
  scopes: scopes,
222
+ interceptors: interceptors,
208
223
  &Google::Cloud::Dialogflow::V2::Agents::Stub.method(:new)
209
224
  )
210
225
 
211
226
  @get_agent = Google::Gax.create_api_call(
212
227
  @agents_stub.method(:get_agent),
213
- defaults["get_agent"]
228
+ defaults["get_agent"],
229
+ exception_transformer: exception_transformer
214
230
  )
215
231
  @search_agents = Google::Gax.create_api_call(
216
232
  @agents_stub.method(:search_agents),
217
- defaults["search_agents"]
233
+ defaults["search_agents"],
234
+ exception_transformer: exception_transformer
218
235
  )
219
236
  @train_agent = Google::Gax.create_api_call(
220
237
  @agents_stub.method(:train_agent),
221
- defaults["train_agent"]
238
+ defaults["train_agent"],
239
+ exception_transformer: exception_transformer
222
240
  )
223
241
  @export_agent = Google::Gax.create_api_call(
224
242
  @agents_stub.method(:export_agent),
225
- defaults["export_agent"]
243
+ defaults["export_agent"],
244
+ exception_transformer: exception_transformer
226
245
  )
227
246
  @import_agent = Google::Gax.create_api_call(
228
247
  @agents_stub.method(:import_agent),
229
- defaults["import_agent"]
248
+ defaults["import_agent"],
249
+ exception_transformer: exception_transformer
230
250
  )
231
251
  @restore_agent = Google::Gax.create_api_call(
232
252
  @agents_stub.method(:restore_agent),
233
- defaults["restore_agent"]
253
+ defaults["restore_agent"],
254
+ exception_transformer: exception_transformer
234
255
  )
235
256
  end
236
257
 
@@ -244,23 +265,27 @@ module Google
244
265
  # @param options [Google::Gax::CallOptions]
245
266
  # Overrides the default settings for this call, e.g, timeout,
246
267
  # retries, etc.
268
+ # @yield [result, operation] Access the result along with the RPC operation
269
+ # @yieldparam result [Google::Cloud::Dialogflow::V2::Agent]
270
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
247
271
  # @return [Google::Cloud::Dialogflow::V2::Agent]
248
272
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
249
273
  # @example
250
- # require "google/cloud/dialogflow/v2"
274
+ # require "google/cloud/dialogflow"
251
275
  #
252
- # agents_client = Google::Cloud::Dialogflow::V2::Agents.new
276
+ # agents_client = Google::Cloud::Dialogflow::Agents.new(version: :v2)
253
277
  # formatted_parent = Google::Cloud::Dialogflow::V2::AgentsClient.project_path("[PROJECT]")
254
278
  # response = agents_client.get_agent(formatted_parent)
255
279
 
256
280
  def get_agent \
257
281
  parent,
258
- options: nil
282
+ options: nil,
283
+ &block
259
284
  req = {
260
285
  parent: parent
261
286
  }.delete_if { |_, v| v.nil? }
262
287
  req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::GetAgentRequest)
263
- @get_agent.call(req, options)
288
+ @get_agent.call(req, options, &block)
264
289
  end
265
290
 
266
291
  # Returns the list of agents.
@@ -283,6 +308,9 @@ module Google
283
308
  # @param options [Google::Gax::CallOptions]
284
309
  # Overrides the default settings for this call, e.g, timeout,
285
310
  # retries, etc.
311
+ # @yield [result, operation] Access the result along with the RPC operation
312
+ # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Dialogflow::V2::Agent>]
313
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
286
314
  # @return [Google::Gax::PagedEnumerable<Google::Cloud::Dialogflow::V2::Agent>]
287
315
  # An enumerable of Google::Cloud::Dialogflow::V2::Agent instances.
288
316
  # See Google::Gax::PagedEnumerable documentation for other
@@ -290,9 +318,9 @@ module Google
290
318
  # object.
291
319
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
292
320
  # @example
293
- # require "google/cloud/dialogflow/v2"
321
+ # require "google/cloud/dialogflow"
294
322
  #
295
- # agents_client = Google::Cloud::Dialogflow::V2::Agents.new
323
+ # agents_client = Google::Cloud::Dialogflow::Agents.new(version: :v2)
296
324
  # formatted_parent = Google::Cloud::Dialogflow::V2::AgentsClient.project_path("[PROJECT]")
297
325
  #
298
326
  # # Iterate over all results.
@@ -311,13 +339,14 @@ module Google
311
339
  def search_agents \
312
340
  parent,
313
341
  page_size: nil,
314
- options: nil
342
+ options: nil,
343
+ &block
315
344
  req = {
316
345
  parent: parent,
317
346
  page_size: page_size
318
347
  }.delete_if { |_, v| v.nil? }
319
348
  req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::SearchAgentsRequest)
320
- @search_agents.call(req, options)
349
+ @search_agents.call(req, options, &block)
321
350
  end
322
351
 
323
352
  # Trains the specified agent.
@@ -334,9 +363,9 @@ module Google
334
363
  # @return [Google::Gax::Operation]
335
364
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
336
365
  # @example
337
- # require "google/cloud/dialogflow/v2"
366
+ # require "google/cloud/dialogflow"
338
367
  #
339
- # agents_client = Google::Cloud::Dialogflow::V2::Agents.new
368
+ # agents_client = Google::Cloud::Dialogflow::Agents.new(version: :v2)
340
369
  # formatted_parent = Google::Cloud::Dialogflow::V2::AgentsClient.project_path("[PROJECT]")
341
370
  #
342
371
  # # Register a callback during the method call.
@@ -402,9 +431,9 @@ module Google
402
431
  # @return [Google::Gax::Operation]
403
432
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
404
433
  # @example
405
- # require "google/cloud/dialogflow/v2"
434
+ # require "google/cloud/dialogflow"
406
435
  #
407
- # agents_client = Google::Cloud::Dialogflow::V2::Agents.new
436
+ # agents_client = Google::Cloud::Dialogflow::Agents.new(version: :v2)
408
437
  # formatted_parent = Google::Cloud::Dialogflow::V2::AgentsClient.project_path("[PROJECT]")
409
438
  #
410
439
  # # Register a callback during the method call.
@@ -490,9 +519,9 @@ module Google
490
519
  # @return [Google::Gax::Operation]
491
520
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
492
521
  # @example
493
- # require "google/cloud/dialogflow/v2"
522
+ # require "google/cloud/dialogflow"
494
523
  #
495
- # agents_client = Google::Cloud::Dialogflow::V2::Agents.new
524
+ # agents_client = Google::Cloud::Dialogflow::Agents.new(version: :v2)
496
525
  # formatted_parent = Google::Cloud::Dialogflow::V2::AgentsClient.project_path("[PROJECT]")
497
526
  #
498
527
  # # Register a callback during the method call.
@@ -579,9 +608,9 @@ module Google
579
608
  # @return [Google::Gax::Operation]
580
609
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
581
610
  # @example
582
- # require "google/cloud/dialogflow/v2"
611
+ # require "google/cloud/dialogflow"
583
612
  #
584
- # agents_client = Google::Cloud::Dialogflow::V2::Agents.new
613
+ # agents_client = Google::Cloud::Dialogflow::Agents.new(version: :v2)
585
614
  # formatted_parent = Google::Cloud::Dialogflow::V2::AgentsClient.project_path("[PROJECT]")
586
615
  #
587
616
  # # Register a callback during the method call.