google-cloud-dialogflow 0.14.0 → 1.1.2

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 (55) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -1
  3. data/AUTHENTICATION.md +51 -59
  4. data/LICENSE.md +203 -0
  5. data/MIGRATING.md +445 -0
  6. data/README.md +35 -25
  7. data/lib/{google/cloud/dialogflow/v2/doc/google/protobuf/empty.rb → google-cloud-dialogflow.rb} +4 -14
  8. data/lib/google/cloud/dialogflow.rb +256 -506
  9. data/lib/google/cloud/dialogflow/version.rb +1 -1
  10. metadata +63 -86
  11. data/LICENSE +0 -201
  12. data/lib/google/cloud/dialogflow/v2.rb +0 -598
  13. data/lib/google/cloud/dialogflow/v2/agent_pb.rb +0 -121
  14. data/lib/google/cloud/dialogflow/v2/agent_services_pb.rb +0 -111
  15. data/lib/google/cloud/dialogflow/v2/agents_client.rb +0 -807
  16. data/lib/google/cloud/dialogflow/v2/agents_client_config.json +0 -71
  17. data/lib/google/cloud/dialogflow/v2/audio_config_pb.rb +0 -96
  18. data/lib/google/cloud/dialogflow/v2/context_pb.rb +0 -63
  19. data/lib/google/cloud/dialogflow/v2/context_services_pb.rb +0 -75
  20. data/lib/google/cloud/dialogflow/v2/contexts_client.rb +0 -519
  21. data/lib/google/cloud/dialogflow/v2/contexts_client_config.json +0 -56
  22. data/lib/google/cloud/dialogflow/v2/credentials.rb +0 -42
  23. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/agent.rb +0 -247
  24. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/audio_config.rb +0 -341
  25. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/context.rb +0 -116
  26. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/entity_type.rb +0 -305
  27. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/intent.rb +0 -937
  28. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/session.rb +0 -498
  29. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/session_entity_type.rb +0 -130
  30. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/validation_result.rb +0 -71
  31. data/lib/google/cloud/dialogflow/v2/doc/google/longrunning/operations.rb +0 -51
  32. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/any.rb +0 -131
  33. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/duration.rb +0 -91
  34. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/field_mask.rb +0 -222
  35. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/struct.rb +0 -74
  36. data/lib/google/cloud/dialogflow/v2/doc/google/rpc/status.rb +0 -39
  37. data/lib/google/cloud/dialogflow/v2/doc/google/type/latlng.rb +0 -31
  38. data/lib/google/cloud/dialogflow/v2/entity_type_pb.rb +0 -125
  39. data/lib/google/cloud/dialogflow/v2/entity_type_services_pb.rb +0 -105
  40. data/lib/google/cloud/dialogflow/v2/entity_types_client.rb +0 -994
  41. data/lib/google/cloud/dialogflow/v2/entity_types_client_config.json +0 -76
  42. data/lib/google/cloud/dialogflow/v2/intent_pb.rb +0 -367
  43. data/lib/google/cloud/dialogflow/v2/intent_services_pb.rb +0 -93
  44. data/lib/google/cloud/dialogflow/v2/intents_client.rb +0 -760
  45. data/lib/google/cloud/dialogflow/v2/intents_client_config.json +0 -61
  46. data/lib/google/cloud/dialogflow/v2/session_entity_type_pb.rb +0 -65
  47. data/lib/google/cloud/dialogflow/v2/session_entity_type_services_pb.rb +0 -93
  48. data/lib/google/cloud/dialogflow/v2/session_entity_types_client.rb +0 -504
  49. data/lib/google/cloud/dialogflow/v2/session_entity_types_client_config.json +0 -51
  50. data/lib/google/cloud/dialogflow/v2/session_pb.rb +0 -141
  51. data/lib/google/cloud/dialogflow/v2/session_services_pb.rb +0 -56
  52. data/lib/google/cloud/dialogflow/v2/sessions_client.rb +0 -337
  53. data/lib/google/cloud/dialogflow/v2/sessions_client_config.json +0 -36
  54. data/lib/google/cloud/dialogflow/v2/validation_result_pb.rb +0 -36
  55. data/lib/google/cloud/dialogflow/v2/webhook_pb.rb +0 -46
@@ -1,760 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #
15
- # EDITING INSTRUCTIONS
16
- # This file was generated from the file
17
- # https://github.com/googleapis/googleapis/blob/master/google/cloud/dialogflow/v2/intent.proto,
18
- # and updates to that file get reflected here through a refresh process.
19
- # For the short term, the refresh process will only be runnable by Google
20
- # engineers.
21
-
22
-
23
- require "json"
24
- require "pathname"
25
-
26
- require "google/gax"
27
- require "google/gax/operation"
28
- require "google/longrunning/operations_client"
29
-
30
- require "google/cloud/dialogflow/v2/intent_pb"
31
- require "google/cloud/dialogflow/v2/credentials"
32
- require "google/cloud/dialogflow/version"
33
-
34
- module Google
35
- module Cloud
36
- module Dialogflow
37
- module V2
38
- # An intent represents a mapping between input from a user and an action to
39
- # be taken by your application. When you pass user input to the
40
- # {Google::Cloud::Dialogflow::V2::Sessions::DetectIntent DetectIntent} (or
41
- # {Google::Cloud::Dialogflow::V2::Sessions::StreamingDetectIntent StreamingDetectIntent}) method, the
42
- # Dialogflow API analyzes the input and searches
43
- # for a matching intent. If no match is found, the Dialogflow API returns a
44
- # fallback intent (`is_fallback` = true).
45
- #
46
- # You can provide additional information for the Dialogflow API to use to
47
- # match user input to an intent by adding the following to your intent.
48
- #
49
- # * **Contexts** - provide additional context for intent analysis. For
50
- # example, if an intent is related to an object in your application that
51
- # plays music, you can provide a context to determine when to match the
52
- # intent if the user input is "turn it off". You can include a context
53
- # that matches the intent when there is previous user input of
54
- # "play music", and not when there is previous user input of
55
- # "turn on the light".
56
- #
57
- # * **Events** - allow for matching an intent by using an event name
58
- # instead of user input. Your application can provide an event name and
59
- # related parameters to the Dialogflow API to match an intent. For
60
- # example, when your application starts, you can send a welcome event
61
- # with a user name parameter to the Dialogflow API to match an intent with
62
- # a personalized welcome message for the user.
63
- #
64
- # * **Training phrases** - provide examples of user input to train the
65
- # Dialogflow API agent to better match intents.
66
- #
67
- # For more information about intents, see the
68
- # [Dialogflow
69
- # documentation](https://cloud.google.com/dialogflow/docs/intents-overview).
70
- #
71
- # @!attribute [r] intents_stub
72
- # @return [Google::Cloud::Dialogflow::V2::Intents::Stub]
73
- class IntentsClient
74
- # @private
75
- attr_reader :intents_stub
76
-
77
- # The default address of the service.
78
- SERVICE_ADDRESS = "dialogflow.googleapis.com".freeze
79
-
80
- # The default port of the service.
81
- DEFAULT_SERVICE_PORT = 443
82
-
83
- # The default set of gRPC interceptors.
84
- GRPC_INTERCEPTORS = []
85
-
86
- DEFAULT_TIMEOUT = 30
87
-
88
- PAGE_DESCRIPTORS = {
89
- "list_intents" => Google::Gax::PageDescriptor.new(
90
- "page_token",
91
- "next_page_token",
92
- "intents")
93
- }.freeze
94
-
95
- private_constant :PAGE_DESCRIPTORS
96
-
97
- # The scopes needed to make gRPC calls to all of the methods defined in
98
- # this service.
99
- ALL_SCOPES = [
100
- "https://www.googleapis.com/auth/cloud-platform",
101
- "https://www.googleapis.com/auth/dialogflow"
102
- ].freeze
103
-
104
- # @private
105
- class OperationsClient < Google::Longrunning::OperationsClient
106
- self::SERVICE_ADDRESS = IntentsClient::SERVICE_ADDRESS
107
- self::GRPC_INTERCEPTORS = IntentsClient::GRPC_INTERCEPTORS
108
- end
109
-
110
- AGENT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
111
- "projects/{project}/agents/{agent}"
112
- )
113
-
114
- private_constant :AGENT_PATH_TEMPLATE
115
-
116
- INTENT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
117
- "projects/{project}/agent/intents/{intent}"
118
- )
119
-
120
- private_constant :INTENT_PATH_TEMPLATE
121
-
122
- PROJECT_AGENT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
123
- "projects/{project}/agent"
124
- )
125
-
126
- private_constant :PROJECT_AGENT_PATH_TEMPLATE
127
-
128
- # Returns a fully-qualified agent resource name string.
129
- # @param project [String]
130
- # @param agent [String]
131
- # @return [String]
132
- def self.agent_path project, agent
133
- AGENT_PATH_TEMPLATE.render(
134
- :"project" => project,
135
- :"agent" => agent
136
- )
137
- end
138
-
139
- # Returns a fully-qualified intent resource name string.
140
- # @param project [String]
141
- # @param intent [String]
142
- # @return [String]
143
- def self.intent_path project, intent
144
- INTENT_PATH_TEMPLATE.render(
145
- :"project" => project,
146
- :"intent" => intent
147
- )
148
- end
149
-
150
- # Returns a fully-qualified project_agent resource name string.
151
- # @param project [String]
152
- # @return [String]
153
- def self.project_agent_path project
154
- PROJECT_AGENT_PATH_TEMPLATE.render(
155
- :"project" => project
156
- )
157
- end
158
-
159
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
160
- # Provides the means for authenticating requests made by the client. This parameter can
161
- # be many types.
162
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
163
- # authenticating requests made by this client.
164
- # A `String` will be treated as the path to the keyfile to be used for the construction of
165
- # credentials for this client.
166
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
167
- # credentials for this client.
168
- # A `GRPC::Core::Channel` will be used to make calls through.
169
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
170
- # should already be composed with a `GRPC::Core::CallCredentials` object.
171
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
172
- # metadata for requests, generally, to give OAuth credentials.
173
- # @param scopes [Array<String>]
174
- # The OAuth scopes for this service. This parameter is ignored if
175
- # an updater_proc is supplied.
176
- # @param client_config [Hash]
177
- # A Hash for call options for each method. See
178
- # Google::Gax#construct_settings for the structure of
179
- # this data. Falls back to the default config if not specified
180
- # or the specified config is missing data points.
181
- # @param timeout [Numeric]
182
- # The default timeout, in seconds, for calls made through this client.
183
- # @param metadata [Hash]
184
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
185
- # @param service_address [String]
186
- # Override for the service hostname, or `nil` to leave as the default.
187
- # @param service_port [Integer]
188
- # Override for the service port, or `nil` to leave as the default.
189
- # @param exception_transformer [Proc]
190
- # An optional proc that intercepts any exceptions raised during an API call to inject
191
- # custom error handling.
192
- def initialize \
193
- credentials: nil,
194
- scopes: ALL_SCOPES,
195
- client_config: {},
196
- timeout: DEFAULT_TIMEOUT,
197
- metadata: nil,
198
- service_address: nil,
199
- service_port: nil,
200
- exception_transformer: nil,
201
- lib_name: nil,
202
- lib_version: ""
203
- # These require statements are intentionally placed here to initialize
204
- # the gRPC module only when it's required.
205
- # See https://github.com/googleapis/toolkit/issues/446
206
- require "google/gax/grpc"
207
- require "google/cloud/dialogflow/v2/intent_services_pb"
208
-
209
- credentials ||= Google::Cloud::Dialogflow::V2::Credentials.default
210
-
211
- @operations_client = OperationsClient.new(
212
- credentials: credentials,
213
- scopes: scopes,
214
- client_config: client_config,
215
- timeout: timeout,
216
- lib_name: lib_name,
217
- service_address: service_address,
218
- service_port: service_port,
219
- lib_version: lib_version,
220
- metadata: metadata,
221
- )
222
-
223
- if credentials.is_a?(String) || credentials.is_a?(Hash)
224
- updater_proc = Google::Cloud::Dialogflow::V2::Credentials.new(credentials).updater_proc
225
- end
226
- if credentials.is_a?(GRPC::Core::Channel)
227
- channel = credentials
228
- end
229
- if credentials.is_a?(GRPC::Core::ChannelCredentials)
230
- chan_creds = credentials
231
- end
232
- if credentials.is_a?(Proc)
233
- updater_proc = credentials
234
- end
235
- if credentials.is_a?(Google::Auth::Credentials)
236
- updater_proc = credentials.updater_proc
237
- end
238
-
239
- package_version = Google::Cloud::Dialogflow::VERSION
240
-
241
- google_api_client = "gl-ruby/#{RUBY_VERSION}"
242
- google_api_client << " #{lib_name}/#{lib_version}" if lib_name
243
- google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
244
- google_api_client << " grpc/#{GRPC::VERSION}"
245
- google_api_client.freeze
246
-
247
- headers = { :"x-goog-api-client" => google_api_client }
248
- headers.merge!(metadata) unless metadata.nil?
249
- client_config_file = Pathname.new(__dir__).join(
250
- "intents_client_config.json"
251
- )
252
- defaults = client_config_file.open do |f|
253
- Google::Gax.construct_settings(
254
- "google.cloud.dialogflow.v2.Intents",
255
- JSON.parse(f.read),
256
- client_config,
257
- Google::Gax::Grpc::STATUS_CODE_NAMES,
258
- timeout,
259
- page_descriptors: PAGE_DESCRIPTORS,
260
- errors: Google::Gax::Grpc::API_ERRORS,
261
- metadata: headers
262
- )
263
- end
264
-
265
- # Allow overriding the service path/port in subclasses.
266
- service_path = service_address || self.class::SERVICE_ADDRESS
267
- port = service_port || self.class::DEFAULT_SERVICE_PORT
268
- interceptors = self.class::GRPC_INTERCEPTORS
269
- @intents_stub = Google::Gax::Grpc.create_stub(
270
- service_path,
271
- port,
272
- chan_creds: chan_creds,
273
- channel: channel,
274
- updater_proc: updater_proc,
275
- scopes: scopes,
276
- interceptors: interceptors,
277
- &Google::Cloud::Dialogflow::V2::Intents::Stub.method(:new)
278
- )
279
-
280
- @list_intents = Google::Gax.create_api_call(
281
- @intents_stub.method(:list_intents),
282
- defaults["list_intents"],
283
- exception_transformer: exception_transformer,
284
- params_extractor: proc do |request|
285
- {'parent' => request.parent}
286
- end
287
- )
288
- @get_intent = Google::Gax.create_api_call(
289
- @intents_stub.method(:get_intent),
290
- defaults["get_intent"],
291
- exception_transformer: exception_transformer,
292
- params_extractor: proc do |request|
293
- {'name' => request.name}
294
- end
295
- )
296
- @create_intent = Google::Gax.create_api_call(
297
- @intents_stub.method(:create_intent),
298
- defaults["create_intent"],
299
- exception_transformer: exception_transformer,
300
- params_extractor: proc do |request|
301
- {'parent' => request.parent}
302
- end
303
- )
304
- @update_intent = Google::Gax.create_api_call(
305
- @intents_stub.method(:update_intent),
306
- defaults["update_intent"],
307
- exception_transformer: exception_transformer,
308
- params_extractor: proc do |request|
309
- {'intent.name' => request.intent.name}
310
- end
311
- )
312
- @delete_intent = Google::Gax.create_api_call(
313
- @intents_stub.method(:delete_intent),
314
- defaults["delete_intent"],
315
- exception_transformer: exception_transformer,
316
- params_extractor: proc do |request|
317
- {'name' => request.name}
318
- end
319
- )
320
- @batch_update_intents = Google::Gax.create_api_call(
321
- @intents_stub.method(:batch_update_intents),
322
- defaults["batch_update_intents"],
323
- exception_transformer: exception_transformer,
324
- params_extractor: proc do |request|
325
- {'parent' => request.parent}
326
- end
327
- )
328
- @batch_delete_intents = Google::Gax.create_api_call(
329
- @intents_stub.method(:batch_delete_intents),
330
- defaults["batch_delete_intents"],
331
- exception_transformer: exception_transformer,
332
- params_extractor: proc do |request|
333
- {'parent' => request.parent}
334
- end
335
- )
336
- end
337
-
338
- # Service calls
339
-
340
- # Returns the list of all intents in the specified agent.
341
- #
342
- # @param parent [String]
343
- # Required. The agent to list all intents from.
344
- # Format: `projects/<Project ID>/agent`.
345
- # @param language_code [String]
346
- # Optional. The language to list training phrases, parameters and rich
347
- # messages for. If not specified, the agent's default language is used.
348
- # [Many
349
- # languages](https://cloud.google.com/dialogflow/docs/reference/language)
350
- # are supported. Note: languages must be enabled in the agent before they can
351
- # be used.
352
- # @param intent_view [Google::Cloud::Dialogflow::V2::IntentView]
353
- # Optional. The resource view to apply to the returned intent.
354
- # @param page_size [Integer]
355
- # The maximum number of resources contained in the underlying API
356
- # response. If page streaming is performed per-resource, this
357
- # parameter does not affect the return value. If page streaming is
358
- # performed per-page, this determines the maximum number of
359
- # resources in a page.
360
- # @param options [Google::Gax::CallOptions]
361
- # Overrides the default settings for this call, e.g, timeout,
362
- # retries, etc.
363
- # @yield [result, operation] Access the result along with the RPC operation
364
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Dialogflow::V2::Intent>]
365
- # @yieldparam operation [GRPC::ActiveCall::Operation]
366
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Dialogflow::V2::Intent>]
367
- # An enumerable of Google::Cloud::Dialogflow::V2::Intent instances.
368
- # See Google::Gax::PagedEnumerable documentation for other
369
- # operations such as per-page iteration or access to the response
370
- # object.
371
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
372
- # @example
373
- # require "google/cloud/dialogflow"
374
- #
375
- # intents_client = Google::Cloud::Dialogflow::Intents.new(version: :v2)
376
- # formatted_parent = Google::Cloud::Dialogflow::V2::IntentsClient.project_agent_path("[PROJECT]")
377
- #
378
- # # Iterate over all results.
379
- # intents_client.list_intents(formatted_parent).each do |element|
380
- # # Process element.
381
- # end
382
- #
383
- # # Or iterate over results one page at a time.
384
- # intents_client.list_intents(formatted_parent).each_page do |page|
385
- # # Process each page at a time.
386
- # page.each do |element|
387
- # # Process element.
388
- # end
389
- # end
390
-
391
- def list_intents \
392
- parent,
393
- language_code: nil,
394
- intent_view: nil,
395
- page_size: nil,
396
- options: nil,
397
- &block
398
- req = {
399
- parent: parent,
400
- language_code: language_code,
401
- intent_view: intent_view,
402
- page_size: page_size
403
- }.delete_if { |_, v| v.nil? }
404
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::ListIntentsRequest)
405
- @list_intents.call(req, options, &block)
406
- end
407
-
408
- # Retrieves the specified intent.
409
- #
410
- # @param name [String]
411
- # Required. The name of the intent.
412
- # Format: `projects/<Project ID>/agent/intents/<Intent ID>`.
413
- # @param language_code [String]
414
- # Optional. The language to retrieve training phrases, parameters and rich
415
- # messages for. If not specified, the agent's default language is used.
416
- # [Many
417
- # languages](https://cloud.google.com/dialogflow/docs/reference/language)
418
- # are supported. Note: languages must be enabled in the agent before they can
419
- # be used.
420
- # @param intent_view [Google::Cloud::Dialogflow::V2::IntentView]
421
- # Optional. The resource view to apply to the returned intent.
422
- # @param options [Google::Gax::CallOptions]
423
- # Overrides the default settings for this call, e.g, timeout,
424
- # retries, etc.
425
- # @yield [result, operation] Access the result along with the RPC operation
426
- # @yieldparam result [Google::Cloud::Dialogflow::V2::Intent]
427
- # @yieldparam operation [GRPC::ActiveCall::Operation]
428
- # @return [Google::Cloud::Dialogflow::V2::Intent]
429
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
430
- # @example
431
- # require "google/cloud/dialogflow"
432
- #
433
- # intents_client = Google::Cloud::Dialogflow::Intents.new(version: :v2)
434
- # formatted_name = Google::Cloud::Dialogflow::V2::IntentsClient.intent_path("[PROJECT]", "[INTENT]")
435
- # response = intents_client.get_intent(formatted_name)
436
-
437
- def get_intent \
438
- name,
439
- language_code: nil,
440
- intent_view: nil,
441
- options: nil,
442
- &block
443
- req = {
444
- name: name,
445
- language_code: language_code,
446
- intent_view: intent_view
447
- }.delete_if { |_, v| v.nil? }
448
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::GetIntentRequest)
449
- @get_intent.call(req, options, &block)
450
- end
451
-
452
- # Creates an intent in the specified agent.
453
- #
454
- # @param parent [String]
455
- # Required. The agent to create a intent for.
456
- # Format: `projects/<Project ID>/agent`.
457
- # @param intent [Google::Cloud::Dialogflow::V2::Intent | Hash]
458
- # Required. The intent to create.
459
- # A hash of the same form as `Google::Cloud::Dialogflow::V2::Intent`
460
- # can also be provided.
461
- # @param language_code [String]
462
- # Optional. The language of training phrases, parameters and rich messages
463
- # defined in `intent`. If not specified, the agent's default language is
464
- # used. [Many
465
- # languages](https://cloud.google.com/dialogflow/docs/reference/language)
466
- # are supported. Note: languages must be enabled in the agent before they can
467
- # be used.
468
- # @param intent_view [Google::Cloud::Dialogflow::V2::IntentView]
469
- # Optional. The resource view to apply to the returned intent.
470
- # @param options [Google::Gax::CallOptions]
471
- # Overrides the default settings for this call, e.g, timeout,
472
- # retries, etc.
473
- # @yield [result, operation] Access the result along with the RPC operation
474
- # @yieldparam result [Google::Cloud::Dialogflow::V2::Intent]
475
- # @yieldparam operation [GRPC::ActiveCall::Operation]
476
- # @return [Google::Cloud::Dialogflow::V2::Intent]
477
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
478
- # @example
479
- # require "google/cloud/dialogflow"
480
- #
481
- # intents_client = Google::Cloud::Dialogflow::Intents.new(version: :v2)
482
- # formatted_parent = Google::Cloud::Dialogflow::V2::IntentsClient.project_agent_path("[PROJECT]")
483
- #
484
- # # TODO: Initialize `intent`:
485
- # intent = {}
486
- # response = intents_client.create_intent(formatted_parent, intent)
487
-
488
- def create_intent \
489
- parent,
490
- intent,
491
- language_code: nil,
492
- intent_view: nil,
493
- options: nil,
494
- &block
495
- req = {
496
- parent: parent,
497
- intent: intent,
498
- language_code: language_code,
499
- intent_view: intent_view
500
- }.delete_if { |_, v| v.nil? }
501
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::CreateIntentRequest)
502
- @create_intent.call(req, options, &block)
503
- end
504
-
505
- # Updates the specified intent.
506
- #
507
- # @param intent [Google::Cloud::Dialogflow::V2::Intent | Hash]
508
- # Required. The intent to update.
509
- # A hash of the same form as `Google::Cloud::Dialogflow::V2::Intent`
510
- # can also be provided.
511
- # @param language_code [String]
512
- # Optional. The language of training phrases, parameters and rich messages
513
- # defined in `intent`. If not specified, the agent's default language is
514
- # used. [Many
515
- # languages](https://cloud.google.com/dialogflow/docs/reference/language)
516
- # are supported. Note: languages must be enabled in the agent before they can
517
- # be used.
518
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
519
- # Optional. The mask to control which fields get updated.
520
- # A hash of the same form as `Google::Protobuf::FieldMask`
521
- # can also be provided.
522
- # @param intent_view [Google::Cloud::Dialogflow::V2::IntentView]
523
- # Optional. The resource view to apply to the returned intent.
524
- # @param options [Google::Gax::CallOptions]
525
- # Overrides the default settings for this call, e.g, timeout,
526
- # retries, etc.
527
- # @yield [result, operation] Access the result along with the RPC operation
528
- # @yieldparam result [Google::Cloud::Dialogflow::V2::Intent]
529
- # @yieldparam operation [GRPC::ActiveCall::Operation]
530
- # @return [Google::Cloud::Dialogflow::V2::Intent]
531
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
532
- # @example
533
- # require "google/cloud/dialogflow"
534
- #
535
- # intents_client = Google::Cloud::Dialogflow::Intents.new(version: :v2)
536
- #
537
- # # TODO: Initialize `intent`:
538
- # intent = {}
539
- # response = intents_client.update_intent(intent)
540
-
541
- def update_intent \
542
- intent,
543
- language_code: nil,
544
- update_mask: nil,
545
- intent_view: nil,
546
- options: nil,
547
- &block
548
- req = {
549
- intent: intent,
550
- language_code: language_code,
551
- update_mask: update_mask,
552
- intent_view: intent_view
553
- }.delete_if { |_, v| v.nil? }
554
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::UpdateIntentRequest)
555
- @update_intent.call(req, options, &block)
556
- end
557
-
558
- # Deletes the specified intent and its direct or indirect followup intents.
559
- #
560
- # @param name [String]
561
- # Required. The name of the intent to delete. If this intent has direct or
562
- # indirect followup intents, we also delete them.
563
- # Format: `projects/<Project ID>/agent/intents/<Intent ID>`.
564
- # @param options [Google::Gax::CallOptions]
565
- # Overrides the default settings for this call, e.g, timeout,
566
- # retries, etc.
567
- # @yield [result, operation] Access the result along with the RPC operation
568
- # @yieldparam result []
569
- # @yieldparam operation [GRPC::ActiveCall::Operation]
570
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
571
- # @example
572
- # require "google/cloud/dialogflow"
573
- #
574
- # intents_client = Google::Cloud::Dialogflow::Intents.new(version: :v2)
575
- # formatted_name = Google::Cloud::Dialogflow::V2::IntentsClient.intent_path("[PROJECT]", "[INTENT]")
576
- # intents_client.delete_intent(formatted_name)
577
-
578
- def delete_intent \
579
- name,
580
- options: nil,
581
- &block
582
- req = {
583
- name: name
584
- }.delete_if { |_, v| v.nil? }
585
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::DeleteIntentRequest)
586
- @delete_intent.call(req, options, &block)
587
- nil
588
- end
589
-
590
- # Updates/Creates multiple intents in the specified agent.
591
- #
592
- # Operation <response: {Google::Cloud::Dialogflow::V2::BatchUpdateIntentsResponse BatchUpdateIntentsResponse}>
593
- #
594
- # @param parent [String]
595
- # Required. The name of the agent to update or create intents in.
596
- # Format: `projects/<Project ID>/agent`.
597
- # @param intent_batch_uri [String]
598
- # The URI to a Google Cloud Storage file containing intents to update or
599
- # create. The file format can either be a serialized proto (of IntentBatch
600
- # type) or JSON object. Note: The URI must start with "gs://".
601
- # @param intent_batch_inline [Google::Cloud::Dialogflow::V2::IntentBatch | Hash]
602
- # The collection of intents to update or create.
603
- # A hash of the same form as `Google::Cloud::Dialogflow::V2::IntentBatch`
604
- # can also be provided.
605
- # @param language_code [String]
606
- # Optional. The language of training phrases, parameters and rich messages
607
- # defined in `intents`. If not specified, the agent's default language is
608
- # used. [Many
609
- # languages](https://cloud.google.com/dialogflow/docs/reference/language)
610
- # are supported. Note: languages must be enabled in the agent before they can
611
- # be used.
612
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
613
- # Optional. The mask to control which fields get updated.
614
- # A hash of the same form as `Google::Protobuf::FieldMask`
615
- # can also be provided.
616
- # @param intent_view [Google::Cloud::Dialogflow::V2::IntentView]
617
- # Optional. The resource view to apply to the returned intent.
618
- # @param options [Google::Gax::CallOptions]
619
- # Overrides the default settings for this call, e.g, timeout,
620
- # retries, etc.
621
- # @return [Google::Gax::Operation]
622
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
623
- # @example
624
- # require "google/cloud/dialogflow"
625
- #
626
- # intents_client = Google::Cloud::Dialogflow::Intents.new(version: :v2)
627
- # formatted_parent = Google::Cloud::Dialogflow::V2::IntentsClient.project_agent_path("[PROJECT]")
628
- #
629
- # # Register a callback during the method call.
630
- # operation = intents_client.batch_update_intents(formatted_parent) do |op|
631
- # raise op.results.message if op.error?
632
- # op_results = op.results
633
- # # Process the results.
634
- #
635
- # metadata = op.metadata
636
- # # Process the metadata.
637
- # end
638
- #
639
- # # Or use the return value to register a callback.
640
- # operation.on_done do |op|
641
- # raise op.results.message if op.error?
642
- # op_results = op.results
643
- # # Process the results.
644
- #
645
- # metadata = op.metadata
646
- # # Process the metadata.
647
- # end
648
- #
649
- # # Manually reload the operation.
650
- # operation.reload!
651
- #
652
- # # Or block until the operation completes, triggering callbacks on
653
- # # completion.
654
- # operation.wait_until_done!
655
-
656
- def batch_update_intents \
657
- parent,
658
- intent_batch_uri: nil,
659
- intent_batch_inline: nil,
660
- language_code: nil,
661
- update_mask: nil,
662
- intent_view: nil,
663
- options: nil
664
- req = {
665
- parent: parent,
666
- intent_batch_uri: intent_batch_uri,
667
- intent_batch_inline: intent_batch_inline,
668
- language_code: language_code,
669
- update_mask: update_mask,
670
- intent_view: intent_view
671
- }.delete_if { |_, v| v.nil? }
672
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::BatchUpdateIntentsRequest)
673
- operation = Google::Gax::Operation.new(
674
- @batch_update_intents.call(req, options),
675
- @operations_client,
676
- Google::Cloud::Dialogflow::V2::BatchUpdateIntentsResponse,
677
- Google::Protobuf::Struct,
678
- call_options: options
679
- )
680
- operation.on_done { |operation| yield(operation) } if block_given?
681
- operation
682
- end
683
-
684
- # Deletes intents in the specified agent.
685
- #
686
- # Operation <response: {Google::Protobuf::Empty}>
687
- #
688
- # @param parent [String]
689
- # Required. The name of the agent to delete all entities types for. Format:
690
- # `projects/<Project ID>/agent`.
691
- # @param intents [Array<Google::Cloud::Dialogflow::V2::Intent | Hash>]
692
- # Required. The collection of intents to delete. Only intent `name` must be
693
- # filled in.
694
- # A hash of the same form as `Google::Cloud::Dialogflow::V2::Intent`
695
- # can also be provided.
696
- # @param options [Google::Gax::CallOptions]
697
- # Overrides the default settings for this call, e.g, timeout,
698
- # retries, etc.
699
- # @return [Google::Gax::Operation]
700
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
701
- # @example
702
- # require "google/cloud/dialogflow"
703
- #
704
- # intents_client = Google::Cloud::Dialogflow::Intents.new(version: :v2)
705
- # formatted_parent = Google::Cloud::Dialogflow::V2::IntentsClient.project_agent_path("[PROJECT]")
706
- #
707
- # # TODO: Initialize `intents`:
708
- # intents = []
709
- #
710
- # # Register a callback during the method call.
711
- # operation = intents_client.batch_delete_intents(formatted_parent, intents) do |op|
712
- # raise op.results.message if op.error?
713
- # op_results = op.results
714
- # # Process the results.
715
- #
716
- # metadata = op.metadata
717
- # # Process the metadata.
718
- # end
719
- #
720
- # # Or use the return value to register a callback.
721
- # operation.on_done do |op|
722
- # raise op.results.message if op.error?
723
- # op_results = op.results
724
- # # Process the results.
725
- #
726
- # metadata = op.metadata
727
- # # Process the metadata.
728
- # end
729
- #
730
- # # Manually reload the operation.
731
- # operation.reload!
732
- #
733
- # # Or block until the operation completes, triggering callbacks on
734
- # # completion.
735
- # operation.wait_until_done!
736
-
737
- def batch_delete_intents \
738
- parent,
739
- intents,
740
- options: nil
741
- req = {
742
- parent: parent,
743
- intents: intents
744
- }.delete_if { |_, v| v.nil? }
745
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::BatchDeleteIntentsRequest)
746
- operation = Google::Gax::Operation.new(
747
- @batch_delete_intents.call(req, options),
748
- @operations_client,
749
- Google::Protobuf::Empty,
750
- Google::Protobuf::Struct,
751
- call_options: options
752
- )
753
- operation.on_done { |operation| yield(operation) } if block_given?
754
- operation
755
- end
756
- end
757
- end
758
- end
759
- end
760
- end