google-cloud-dialogflow 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,7 +27,7 @@ require "google/gax/operation"
27
27
  require "google/longrunning/operations_client"
28
28
 
29
29
  require "google/cloud/dialogflow/v2/intent_pb"
30
- require "google/cloud/dialogflow/credentials"
30
+ require "google/cloud/dialogflow/v2/credentials"
31
31
 
32
32
  module Google
33
33
  module Cloud
@@ -76,6 +76,9 @@ module Google
76
76
  # The default port of the service.
77
77
  DEFAULT_SERVICE_PORT = 443
78
78
 
79
+ # The default set of gRPC interceptors.
80
+ GRPC_INTERCEPTORS = []
81
+
79
82
  DEFAULT_TIMEOUT = 30
80
83
 
81
84
  PAGE_DESCRIPTORS = {
@@ -93,8 +96,10 @@ module Google
93
96
  "https://www.googleapis.com/auth/cloud-platform"
94
97
  ].freeze
95
98
 
99
+ # @private
96
100
  class OperationsClient < Google::Longrunning::OperationsClient
97
101
  self::SERVICE_ADDRESS = IntentsClient::SERVICE_ADDRESS
102
+ self::GRPC_INTERCEPTORS = IntentsClient::GRPC_INTERCEPTORS
98
103
  end
99
104
 
100
105
  PROJECT_AGENT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
@@ -170,11 +175,18 @@ module Google
170
175
  # or the specified config is missing data points.
171
176
  # @param timeout [Numeric]
172
177
  # The default timeout, in seconds, for calls made through this client.
178
+ # @param metadata [Hash]
179
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
180
+ # @param exception_transformer [Proc]
181
+ # An optional proc that intercepts any exceptions raised during an API call to inject
182
+ # custom error handling.
173
183
  def initialize \
174
184
  credentials: nil,
175
185
  scopes: ALL_SCOPES,
176
186
  client_config: {},
177
187
  timeout: DEFAULT_TIMEOUT,
188
+ metadata: nil,
189
+ exception_transformer: nil,
178
190
  lib_name: nil,
179
191
  lib_version: ""
180
192
  # These require statements are intentionally placed here to initialize
@@ -183,7 +195,7 @@ module Google
183
195
  require "google/gax/grpc"
184
196
  require "google/cloud/dialogflow/v2/intent_services_pb"
185
197
 
186
- credentials ||= Google::Cloud::Dialogflow::Credentials.default
198
+ credentials ||= Google::Cloud::Dialogflow::V2::Credentials.default
187
199
 
188
200
  @operations_client = OperationsClient.new(
189
201
  credentials: credentials,
@@ -195,7 +207,7 @@ module Google
195
207
  )
196
208
 
197
209
  if credentials.is_a?(String) || credentials.is_a?(Hash)
198
- updater_proc = Google::Cloud::Dialogflow::Credentials.new(credentials).updater_proc
210
+ updater_proc = Google::Cloud::Dialogflow::V2::Credentials.new(credentials).updater_proc
199
211
  end
200
212
  if credentials.is_a?(GRPC::Core::Channel)
201
213
  channel = credentials
@@ -219,6 +231,7 @@ module Google
219
231
  google_api_client.freeze
220
232
 
221
233
  headers = { :"x-goog-api-client" => google_api_client }
234
+ headers.merge!(metadata) unless metadata.nil?
222
235
  client_config_file = Pathname.new(__dir__).join(
223
236
  "intents_client_config.json"
224
237
  )
@@ -231,13 +244,14 @@ module Google
231
244
  timeout,
232
245
  page_descriptors: PAGE_DESCRIPTORS,
233
246
  errors: Google::Gax::Grpc::API_ERRORS,
234
- kwargs: headers
247
+ metadata: headers
235
248
  )
236
249
  end
237
250
 
238
251
  # Allow overriding the service path/port in subclasses.
239
252
  service_path = self.class::SERVICE_ADDRESS
240
253
  port = self.class::DEFAULT_SERVICE_PORT
254
+ interceptors = self.class::GRPC_INTERCEPTORS
241
255
  @intents_stub = Google::Gax::Grpc.create_stub(
242
256
  service_path,
243
257
  port,
@@ -245,36 +259,44 @@ module Google
245
259
  channel: channel,
246
260
  updater_proc: updater_proc,
247
261
  scopes: scopes,
262
+ interceptors: interceptors,
248
263
  &Google::Cloud::Dialogflow::V2::Intents::Stub.method(:new)
249
264
  )
250
265
 
251
266
  @list_intents = Google::Gax.create_api_call(
252
267
  @intents_stub.method(:list_intents),
253
- defaults["list_intents"]
268
+ defaults["list_intents"],
269
+ exception_transformer: exception_transformer
254
270
  )
255
271
  @get_intent = Google::Gax.create_api_call(
256
272
  @intents_stub.method(:get_intent),
257
- defaults["get_intent"]
273
+ defaults["get_intent"],
274
+ exception_transformer: exception_transformer
258
275
  )
259
276
  @create_intent = Google::Gax.create_api_call(
260
277
  @intents_stub.method(:create_intent),
261
- defaults["create_intent"]
278
+ defaults["create_intent"],
279
+ exception_transformer: exception_transformer
262
280
  )
263
281
  @update_intent = Google::Gax.create_api_call(
264
282
  @intents_stub.method(:update_intent),
265
- defaults["update_intent"]
283
+ defaults["update_intent"],
284
+ exception_transformer: exception_transformer
266
285
  )
267
286
  @delete_intent = Google::Gax.create_api_call(
268
287
  @intents_stub.method(:delete_intent),
269
- defaults["delete_intent"]
288
+ defaults["delete_intent"],
289
+ exception_transformer: exception_transformer
270
290
  )
271
291
  @batch_update_intents = Google::Gax.create_api_call(
272
292
  @intents_stub.method(:batch_update_intents),
273
- defaults["batch_update_intents"]
293
+ defaults["batch_update_intents"],
294
+ exception_transformer: exception_transformer
274
295
  )
275
296
  @batch_delete_intents = Google::Gax.create_api_call(
276
297
  @intents_stub.method(:batch_delete_intents),
277
- defaults["batch_delete_intents"]
298
+ defaults["batch_delete_intents"],
299
+ exception_transformer: exception_transformer
278
300
  )
279
301
  end
280
302
 
@@ -302,6 +324,9 @@ module Google
302
324
  # @param options [Google::Gax::CallOptions]
303
325
  # Overrides the default settings for this call, e.g, timeout,
304
326
  # retries, etc.
327
+ # @yield [result, operation] Access the result along with the RPC operation
328
+ # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Dialogflow::V2::Intent>]
329
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
305
330
  # @return [Google::Gax::PagedEnumerable<Google::Cloud::Dialogflow::V2::Intent>]
306
331
  # An enumerable of Google::Cloud::Dialogflow::V2::Intent instances.
307
332
  # See Google::Gax::PagedEnumerable documentation for other
@@ -309,9 +334,9 @@ module Google
309
334
  # object.
310
335
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
311
336
  # @example
312
- # require "google/cloud/dialogflow/v2"
337
+ # require "google/cloud/dialogflow"
313
338
  #
314
- # intents_client = Google::Cloud::Dialogflow::V2::Intents.new
339
+ # intents_client = Google::Cloud::Dialogflow::Intents.new(version: :v2)
315
340
  # formatted_parent = Google::Cloud::Dialogflow::V2::IntentsClient.project_agent_path("[PROJECT]")
316
341
  #
317
342
  # # Iterate over all results.
@@ -332,7 +357,8 @@ module Google
332
357
  language_code: nil,
333
358
  intent_view: nil,
334
359
  page_size: nil,
335
- options: nil
360
+ options: nil,
361
+ &block
336
362
  req = {
337
363
  parent: parent,
338
364
  language_code: language_code,
@@ -340,7 +366,7 @@ module Google
340
366
  page_size: page_size
341
367
  }.delete_if { |_, v| v.nil? }
342
368
  req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::ListIntentsRequest)
343
- @list_intents.call(req, options)
369
+ @list_intents.call(req, options, &block)
344
370
  end
345
371
 
346
372
  # Retrieves the specified intent.
@@ -359,12 +385,15 @@ module Google
359
385
  # @param options [Google::Gax::CallOptions]
360
386
  # Overrides the default settings for this call, e.g, timeout,
361
387
  # retries, etc.
388
+ # @yield [result, operation] Access the result along with the RPC operation
389
+ # @yieldparam result [Google::Cloud::Dialogflow::V2::Intent]
390
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
362
391
  # @return [Google::Cloud::Dialogflow::V2::Intent]
363
392
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
364
393
  # @example
365
- # require "google/cloud/dialogflow/v2"
394
+ # require "google/cloud/dialogflow"
366
395
  #
367
- # intents_client = Google::Cloud::Dialogflow::V2::Intents.new
396
+ # intents_client = Google::Cloud::Dialogflow::Intents.new(version: :v2)
368
397
  # formatted_name = Google::Cloud::Dialogflow::V2::IntentsClient.intent_path("[PROJECT]", "[INTENT]")
369
398
  # response = intents_client.get_intent(formatted_name)
370
399
 
@@ -372,14 +401,15 @@ module Google
372
401
  name,
373
402
  language_code: nil,
374
403
  intent_view: nil,
375
- options: nil
404
+ options: nil,
405
+ &block
376
406
  req = {
377
407
  name: name,
378
408
  language_code: language_code,
379
409
  intent_view: intent_view
380
410
  }.delete_if { |_, v| v.nil? }
381
411
  req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::GetIntentRequest)
382
- @get_intent.call(req, options)
412
+ @get_intent.call(req, options, &block)
383
413
  end
384
414
 
385
415
  # Creates an intent in the specified agent.
@@ -402,12 +432,15 @@ module Google
402
432
  # @param options [Google::Gax::CallOptions]
403
433
  # Overrides the default settings for this call, e.g, timeout,
404
434
  # retries, etc.
435
+ # @yield [result, operation] Access the result along with the RPC operation
436
+ # @yieldparam result [Google::Cloud::Dialogflow::V2::Intent]
437
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
405
438
  # @return [Google::Cloud::Dialogflow::V2::Intent]
406
439
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
407
440
  # @example
408
- # require "google/cloud/dialogflow/v2"
441
+ # require "google/cloud/dialogflow"
409
442
  #
410
- # intents_client = Google::Cloud::Dialogflow::V2::Intents.new
443
+ # intents_client = Google::Cloud::Dialogflow::Intents.new(version: :v2)
411
444
  # formatted_parent = Google::Cloud::Dialogflow::V2::IntentsClient.project_agent_path("[PROJECT]")
412
445
  #
413
446
  # # TODO: Initialize +intent+:
@@ -419,7 +452,8 @@ module Google
419
452
  intent,
420
453
  language_code: nil,
421
454
  intent_view: nil,
422
- options: nil
455
+ options: nil,
456
+ &block
423
457
  req = {
424
458
  parent: parent,
425
459
  intent: intent,
@@ -427,7 +461,7 @@ module Google
427
461
  intent_view: intent_view
428
462
  }.delete_if { |_, v| v.nil? }
429
463
  req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::CreateIntentRequest)
430
- @create_intent.call(req, options)
464
+ @create_intent.call(req, options, &block)
431
465
  end
432
466
 
433
467
  # Updates the specified intent.
@@ -452,12 +486,15 @@ module Google
452
486
  # @param options [Google::Gax::CallOptions]
453
487
  # Overrides the default settings for this call, e.g, timeout,
454
488
  # retries, etc.
489
+ # @yield [result, operation] Access the result along with the RPC operation
490
+ # @yieldparam result [Google::Cloud::Dialogflow::V2::Intent]
491
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
455
492
  # @return [Google::Cloud::Dialogflow::V2::Intent]
456
493
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
457
494
  # @example
458
- # require "google/cloud/dialogflow/v2"
495
+ # require "google/cloud/dialogflow"
459
496
  #
460
- # intents_client = Google::Cloud::Dialogflow::V2::Intents.new
497
+ # intents_client = Google::Cloud::Dialogflow::Intents.new(version: :v2)
461
498
  #
462
499
  # # TODO: Initialize +intent+:
463
500
  # intent = {}
@@ -471,7 +508,8 @@ module Google
471
508
  language_code,
472
509
  update_mask: nil,
473
510
  intent_view: nil,
474
- options: nil
511
+ options: nil,
512
+ &block
475
513
  req = {
476
514
  intent: intent,
477
515
  language_code: language_code,
@@ -479,7 +517,7 @@ module Google
479
517
  intent_view: intent_view
480
518
  }.delete_if { |_, v| v.nil? }
481
519
  req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::UpdateIntentRequest)
482
- @update_intent.call(req, options)
520
+ @update_intent.call(req, options, &block)
483
521
  end
484
522
 
485
523
  # Deletes the specified intent.
@@ -490,22 +528,26 @@ module Google
490
528
  # @param options [Google::Gax::CallOptions]
491
529
  # Overrides the default settings for this call, e.g, timeout,
492
530
  # retries, etc.
531
+ # @yield [result, operation] Access the result along with the RPC operation
532
+ # @yieldparam result []
533
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
493
534
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
494
535
  # @example
495
- # require "google/cloud/dialogflow/v2"
536
+ # require "google/cloud/dialogflow"
496
537
  #
497
- # intents_client = Google::Cloud::Dialogflow::V2::Intents.new
538
+ # intents_client = Google::Cloud::Dialogflow::Intents.new(version: :v2)
498
539
  # formatted_name = Google::Cloud::Dialogflow::V2::IntentsClient.intent_path("[PROJECT]", "[INTENT]")
499
540
  # intents_client.delete_intent(formatted_name)
500
541
 
501
542
  def delete_intent \
502
543
  name,
503
- options: nil
544
+ options: nil,
545
+ &block
504
546
  req = {
505
547
  name: name
506
548
  }.delete_if { |_, v| v.nil? }
507
549
  req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::DeleteIntentRequest)
508
- @delete_intent.call(req, options)
550
+ @delete_intent.call(req, options, &block)
509
551
  nil
510
552
  end
511
553
 
@@ -542,9 +584,9 @@ module Google
542
584
  # @return [Google::Gax::Operation]
543
585
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
544
586
  # @example
545
- # require "google/cloud/dialogflow/v2"
587
+ # require "google/cloud/dialogflow"
546
588
  #
547
- # intents_client = Google::Cloud::Dialogflow::V2::Intents.new
589
+ # intents_client = Google::Cloud::Dialogflow::Intents.new(version: :v2)
548
590
  # formatted_parent = Google::Cloud::Dialogflow::V2::IntentsClient.project_agent_path("[PROJECT]")
549
591
  #
550
592
  # # TODO: Initialize +language_code+:
@@ -623,9 +665,9 @@ module Google
623
665
  # @return [Google::Gax::Operation]
624
666
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
625
667
  # @example
626
- # require "google/cloud/dialogflow/v2"
668
+ # require "google/cloud/dialogflow"
627
669
  #
628
- # intents_client = Google::Cloud::Dialogflow::V2::Intents.new
670
+ # intents_client = Google::Cloud::Dialogflow::Intents.new(version: :v2)
629
671
  # formatted_parent = Google::Cloud::Dialogflow::V2::IntentsClient.project_agent_path("[PROJECT]")
630
672
  #
631
673
  # # TODO: Initialize +intents+:
@@ -25,7 +25,7 @@ require "pathname"
25
25
  require "google/gax"
26
26
 
27
27
  require "google/cloud/dialogflow/v2/session_entity_type_pb"
28
- require "google/cloud/dialogflow/credentials"
28
+ require "google/cloud/dialogflow/v2/credentials"
29
29
 
30
30
  module Google
31
31
  module Cloud
@@ -55,6 +55,9 @@ module Google
55
55
  # The default port of the service.
56
56
  DEFAULT_SERVICE_PORT = 443
57
57
 
58
+ # The default set of gRPC interceptors.
59
+ GRPC_INTERCEPTORS = []
60
+
58
61
  DEFAULT_TIMEOUT = 30
59
62
 
60
63
  PAGE_DESCRIPTORS = {
@@ -133,11 +136,18 @@ module Google
133
136
  # or the specified config is missing data points.
134
137
  # @param timeout [Numeric]
135
138
  # The default timeout, in seconds, for calls made through this client.
139
+ # @param metadata [Hash]
140
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
141
+ # @param exception_transformer [Proc]
142
+ # An optional proc that intercepts any exceptions raised during an API call to inject
143
+ # custom error handling.
136
144
  def initialize \
137
145
  credentials: nil,
138
146
  scopes: ALL_SCOPES,
139
147
  client_config: {},
140
148
  timeout: DEFAULT_TIMEOUT,
149
+ metadata: nil,
150
+ exception_transformer: nil,
141
151
  lib_name: nil,
142
152
  lib_version: ""
143
153
  # These require statements are intentionally placed here to initialize
@@ -146,10 +156,10 @@ module Google
146
156
  require "google/gax/grpc"
147
157
  require "google/cloud/dialogflow/v2/session_entity_type_services_pb"
148
158
 
149
- credentials ||= Google::Cloud::Dialogflow::Credentials.default
159
+ credentials ||= Google::Cloud::Dialogflow::V2::Credentials.default
150
160
 
151
161
  if credentials.is_a?(String) || credentials.is_a?(Hash)
152
- updater_proc = Google::Cloud::Dialogflow::Credentials.new(credentials).updater_proc
162
+ updater_proc = Google::Cloud::Dialogflow::V2::Credentials.new(credentials).updater_proc
153
163
  end
154
164
  if credentials.is_a?(GRPC::Core::Channel)
155
165
  channel = credentials
@@ -173,6 +183,7 @@ module Google
173
183
  google_api_client.freeze
174
184
 
175
185
  headers = { :"x-goog-api-client" => google_api_client }
186
+ headers.merge!(metadata) unless metadata.nil?
176
187
  client_config_file = Pathname.new(__dir__).join(
177
188
  "session_entity_types_client_config.json"
178
189
  )
@@ -185,13 +196,14 @@ module Google
185
196
  timeout,
186
197
  page_descriptors: PAGE_DESCRIPTORS,
187
198
  errors: Google::Gax::Grpc::API_ERRORS,
188
- kwargs: headers
199
+ metadata: headers
189
200
  )
190
201
  end
191
202
 
192
203
  # Allow overriding the service path/port in subclasses.
193
204
  service_path = self.class::SERVICE_ADDRESS
194
205
  port = self.class::DEFAULT_SERVICE_PORT
206
+ interceptors = self.class::GRPC_INTERCEPTORS
195
207
  @session_entity_types_stub = Google::Gax::Grpc.create_stub(
196
208
  service_path,
197
209
  port,
@@ -199,28 +211,34 @@ module Google
199
211
  channel: channel,
200
212
  updater_proc: updater_proc,
201
213
  scopes: scopes,
214
+ interceptors: interceptors,
202
215
  &Google::Cloud::Dialogflow::V2::SessionEntityTypes::Stub.method(:new)
203
216
  )
204
217
 
205
218
  @list_session_entity_types = Google::Gax.create_api_call(
206
219
  @session_entity_types_stub.method(:list_session_entity_types),
207
- defaults["list_session_entity_types"]
220
+ defaults["list_session_entity_types"],
221
+ exception_transformer: exception_transformer
208
222
  )
209
223
  @get_session_entity_type = Google::Gax.create_api_call(
210
224
  @session_entity_types_stub.method(:get_session_entity_type),
211
- defaults["get_session_entity_type"]
225
+ defaults["get_session_entity_type"],
226
+ exception_transformer: exception_transformer
212
227
  )
213
228
  @create_session_entity_type = Google::Gax.create_api_call(
214
229
  @session_entity_types_stub.method(:create_session_entity_type),
215
- defaults["create_session_entity_type"]
230
+ defaults["create_session_entity_type"],
231
+ exception_transformer: exception_transformer
216
232
  )
217
233
  @update_session_entity_type = Google::Gax.create_api_call(
218
234
  @session_entity_types_stub.method(:update_session_entity_type),
219
- defaults["update_session_entity_type"]
235
+ defaults["update_session_entity_type"],
236
+ exception_transformer: exception_transformer
220
237
  )
221
238
  @delete_session_entity_type = Google::Gax.create_api_call(
222
239
  @session_entity_types_stub.method(:delete_session_entity_type),
223
- defaults["delete_session_entity_type"]
240
+ defaults["delete_session_entity_type"],
241
+ exception_transformer: exception_transformer
224
242
  )
225
243
  end
226
244
 
@@ -240,6 +258,9 @@ module Google
240
258
  # @param options [Google::Gax::CallOptions]
241
259
  # Overrides the default settings for this call, e.g, timeout,
242
260
  # retries, etc.
261
+ # @yield [result, operation] Access the result along with the RPC operation
262
+ # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Dialogflow::V2::SessionEntityType>]
263
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
243
264
  # @return [Google::Gax::PagedEnumerable<Google::Cloud::Dialogflow::V2::SessionEntityType>]
244
265
  # An enumerable of Google::Cloud::Dialogflow::V2::SessionEntityType instances.
245
266
  # See Google::Gax::PagedEnumerable documentation for other
@@ -247,9 +268,9 @@ module Google
247
268
  # object.
248
269
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
249
270
  # @example
250
- # require "google/cloud/dialogflow/v2"
271
+ # require "google/cloud/dialogflow"
251
272
  #
252
- # session_entity_types_client = Google::Cloud::Dialogflow::V2::SessionEntityTypes.new
273
+ # session_entity_types_client = Google::Cloud::Dialogflow::SessionEntityTypes.new(version: :v2)
253
274
  # formatted_parent = Google::Cloud::Dialogflow::V2::SessionEntityTypesClient.session_path("[PROJECT]", "[SESSION]")
254
275
  #
255
276
  # # Iterate over all results.
@@ -268,13 +289,14 @@ module Google
268
289
  def list_session_entity_types \
269
290
  parent,
270
291
  page_size: nil,
271
- options: nil
292
+ options: nil,
293
+ &block
272
294
  req = {
273
295
  parent: parent,
274
296
  page_size: page_size
275
297
  }.delete_if { |_, v| v.nil? }
276
298
  req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::ListSessionEntityTypesRequest)
277
- @list_session_entity_types.call(req, options)
299
+ @list_session_entity_types.call(req, options, &block)
278
300
  end
279
301
 
280
302
  # Retrieves the specified session entity type.
@@ -286,23 +308,27 @@ module Google
286
308
  # @param options [Google::Gax::CallOptions]
287
309
  # Overrides the default settings for this call, e.g, timeout,
288
310
  # retries, etc.
311
+ # @yield [result, operation] Access the result along with the RPC operation
312
+ # @yieldparam result [Google::Cloud::Dialogflow::V2::SessionEntityType]
313
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
289
314
  # @return [Google::Cloud::Dialogflow::V2::SessionEntityType]
290
315
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
291
316
  # @example
292
- # require "google/cloud/dialogflow/v2"
317
+ # require "google/cloud/dialogflow"
293
318
  #
294
- # session_entity_types_client = Google::Cloud::Dialogflow::V2::SessionEntityTypes.new
319
+ # session_entity_types_client = Google::Cloud::Dialogflow::SessionEntityTypes.new(version: :v2)
295
320
  # formatted_name = Google::Cloud::Dialogflow::V2::SessionEntityTypesClient.session_entity_type_path("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]")
296
321
  # response = session_entity_types_client.get_session_entity_type(formatted_name)
297
322
 
298
323
  def get_session_entity_type \
299
324
  name,
300
- options: nil
325
+ options: nil,
326
+ &block
301
327
  req = {
302
328
  name: name
303
329
  }.delete_if { |_, v| v.nil? }
304
330
  req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::GetSessionEntityTypeRequest)
305
- @get_session_entity_type.call(req, options)
331
+ @get_session_entity_type.call(req, options, &block)
306
332
  end
307
333
 
308
334
  # Creates a session entity type.
@@ -317,12 +343,15 @@ module Google
317
343
  # @param options [Google::Gax::CallOptions]
318
344
  # Overrides the default settings for this call, e.g, timeout,
319
345
  # retries, etc.
346
+ # @yield [result, operation] Access the result along with the RPC operation
347
+ # @yieldparam result [Google::Cloud::Dialogflow::V2::SessionEntityType]
348
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
320
349
  # @return [Google::Cloud::Dialogflow::V2::SessionEntityType]
321
350
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
322
351
  # @example
323
- # require "google/cloud/dialogflow/v2"
352
+ # require "google/cloud/dialogflow"
324
353
  #
325
- # session_entity_types_client = Google::Cloud::Dialogflow::V2::SessionEntityTypes.new
354
+ # session_entity_types_client = Google::Cloud::Dialogflow::SessionEntityTypes.new(version: :v2)
326
355
  # formatted_parent = Google::Cloud::Dialogflow::V2::SessionEntityTypesClient.session_path("[PROJECT]", "[SESSION]")
327
356
  #
328
357
  # # TODO: Initialize +session_entity_type+:
@@ -332,13 +361,14 @@ module Google
332
361
  def create_session_entity_type \
333
362
  parent,
334
363
  session_entity_type,
335
- options: nil
364
+ options: nil,
365
+ &block
336
366
  req = {
337
367
  parent: parent,
338
368
  session_entity_type: session_entity_type
339
369
  }.delete_if { |_, v| v.nil? }
340
370
  req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::CreateSessionEntityTypeRequest)
341
- @create_session_entity_type.call(req, options)
371
+ @create_session_entity_type.call(req, options, &block)
342
372
  end
343
373
 
344
374
  # Updates the specified session entity type.
@@ -356,12 +386,15 @@ module Google
356
386
  # @param options [Google::Gax::CallOptions]
357
387
  # Overrides the default settings for this call, e.g, timeout,
358
388
  # retries, etc.
389
+ # @yield [result, operation] Access the result along with the RPC operation
390
+ # @yieldparam result [Google::Cloud::Dialogflow::V2::SessionEntityType]
391
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
359
392
  # @return [Google::Cloud::Dialogflow::V2::SessionEntityType]
360
393
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
361
394
  # @example
362
- # require "google/cloud/dialogflow/v2"
395
+ # require "google/cloud/dialogflow"
363
396
  #
364
- # session_entity_types_client = Google::Cloud::Dialogflow::V2::SessionEntityTypes.new
397
+ # session_entity_types_client = Google::Cloud::Dialogflow::SessionEntityTypes.new(version: :v2)
365
398
  #
366
399
  # # TODO: Initialize +session_entity_type+:
367
400
  # session_entity_type = {}
@@ -370,13 +403,14 @@ module Google
370
403
  def update_session_entity_type \
371
404
  session_entity_type,
372
405
  update_mask: nil,
373
- options: nil
406
+ options: nil,
407
+ &block
374
408
  req = {
375
409
  session_entity_type: session_entity_type,
376
410
  update_mask: update_mask
377
411
  }.delete_if { |_, v| v.nil? }
378
412
  req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::UpdateSessionEntityTypeRequest)
379
- @update_session_entity_type.call(req, options)
413
+ @update_session_entity_type.call(req, options, &block)
380
414
  end
381
415
 
382
416
  # Deletes the specified session entity type.
@@ -388,22 +422,26 @@ module Google
388
422
  # @param options [Google::Gax::CallOptions]
389
423
  # Overrides the default settings for this call, e.g, timeout,
390
424
  # retries, etc.
425
+ # @yield [result, operation] Access the result along with the RPC operation
426
+ # @yieldparam result []
427
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
391
428
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
392
429
  # @example
393
- # require "google/cloud/dialogflow/v2"
430
+ # require "google/cloud/dialogflow"
394
431
  #
395
- # session_entity_types_client = Google::Cloud::Dialogflow::V2::SessionEntityTypes.new
432
+ # session_entity_types_client = Google::Cloud::Dialogflow::SessionEntityTypes.new(version: :v2)
396
433
  # formatted_name = Google::Cloud::Dialogflow::V2::SessionEntityTypesClient.session_entity_type_path("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]")
397
434
  # session_entity_types_client.delete_session_entity_type(formatted_name)
398
435
 
399
436
  def delete_session_entity_type \
400
437
  name,
401
- options: nil
438
+ options: nil,
439
+ &block
402
440
  req = {
403
441
  name: name
404
442
  }.delete_if { |_, v| v.nil? }
405
443
  req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::DeleteSessionEntityTypeRequest)
406
- @delete_session_entity_type.call(req, options)
444
+ @delete_session_entity_type.call(req, options, &block)
407
445
  nil
408
446
  end
409
447
  end