google-cloud-dialogflow 0.15.0 → 1.0.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.
- checksums.yaml +4 -4
- data/.yardopts +2 -1
- data/AUTHENTICATION.md +51 -59
- data/LICENSE.md +203 -0
- data/MIGRATING.md +397 -0
- data/README.md +35 -25
- data/lib/{google/cloud/dialogflow/v2/doc/google/protobuf/empty.rb → google-cloud-dialogflow.rb} +4 -14
- data/lib/google/cloud/dialogflow.rb +368 -506
- data/lib/google/cloud/dialogflow/version.rb +1 -1
- metadata +88 -83
- data/LICENSE +0 -201
- data/lib/google/cloud/dialogflow/v2.rb +0 -598
- data/lib/google/cloud/dialogflow/v2/agent_pb.rb +0 -121
- data/lib/google/cloud/dialogflow/v2/agent_services_pb.rb +0 -111
- data/lib/google/cloud/dialogflow/v2/agents_client.rb +0 -810
- data/lib/google/cloud/dialogflow/v2/agents_client_config.json +0 -71
- data/lib/google/cloud/dialogflow/v2/audio_config_pb.rb +0 -96
- data/lib/google/cloud/dialogflow/v2/context_pb.rb +0 -63
- data/lib/google/cloud/dialogflow/v2/context_services_pb.rb +0 -75
- data/lib/google/cloud/dialogflow/v2/contexts_client.rb +0 -522
- data/lib/google/cloud/dialogflow/v2/contexts_client_config.json +0 -56
- data/lib/google/cloud/dialogflow/v2/credentials.rb +0 -42
- data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/agent.rb +0 -247
- data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/audio_config.rb +0 -341
- data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/context.rb +0 -116
- data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/entity_type.rb +0 -305
- data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/intent.rb +0 -937
- data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/session.rb +0 -498
- data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/session_entity_type.rb +0 -130
- data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/validation_result.rb +0 -71
- data/lib/google/cloud/dialogflow/v2/doc/google/longrunning/operations.rb +0 -51
- data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/duration.rb +0 -91
- data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/field_mask.rb +0 -222
- data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/struct.rb +0 -74
- data/lib/google/cloud/dialogflow/v2/doc/google/rpc/status.rb +0 -39
- data/lib/google/cloud/dialogflow/v2/doc/google/type/latlng.rb +0 -31
- data/lib/google/cloud/dialogflow/v2/entity_type_pb.rb +0 -125
- data/lib/google/cloud/dialogflow/v2/entity_type_services_pb.rb +0 -105
- data/lib/google/cloud/dialogflow/v2/entity_types_client.rb +0 -997
- data/lib/google/cloud/dialogflow/v2/entity_types_client_config.json +0 -76
- data/lib/google/cloud/dialogflow/v2/intent_pb.rb +0 -367
- data/lib/google/cloud/dialogflow/v2/intent_services_pb.rb +0 -93
- data/lib/google/cloud/dialogflow/v2/intents_client.rb +0 -763
- data/lib/google/cloud/dialogflow/v2/intents_client_config.json +0 -61
- data/lib/google/cloud/dialogflow/v2/session_entity_type_pb.rb +0 -65
- data/lib/google/cloud/dialogflow/v2/session_entity_type_services_pb.rb +0 -93
- data/lib/google/cloud/dialogflow/v2/session_entity_types_client.rb +0 -507
- data/lib/google/cloud/dialogflow/v2/session_entity_types_client_config.json +0 -51
- data/lib/google/cloud/dialogflow/v2/session_pb.rb +0 -141
- data/lib/google/cloud/dialogflow/v2/session_services_pb.rb +0 -56
- data/lib/google/cloud/dialogflow/v2/sessions_client.rb +0 -340
- data/lib/google/cloud/dialogflow/v2/sessions_client_config.json +0 -36
- data/lib/google/cloud/dialogflow/v2/validation_result_pb.rb +0 -36
- data/lib/google/cloud/dialogflow/v2/webhook_pb.rb +0 -46
@@ -1,763 +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
|
-
if credentials.respond_to?(:quota_project_id) && credentials.quota_project_id
|
249
|
-
headers[:"x-goog-user-project"] = credentials.quota_project_id
|
250
|
-
end
|
251
|
-
headers.merge!(metadata) unless metadata.nil?
|
252
|
-
client_config_file = Pathname.new(__dir__).join(
|
253
|
-
"intents_client_config.json"
|
254
|
-
)
|
255
|
-
defaults = client_config_file.open do |f|
|
256
|
-
Google::Gax.construct_settings(
|
257
|
-
"google.cloud.dialogflow.v2.Intents",
|
258
|
-
JSON.parse(f.read),
|
259
|
-
client_config,
|
260
|
-
Google::Gax::Grpc::STATUS_CODE_NAMES,
|
261
|
-
timeout,
|
262
|
-
page_descriptors: PAGE_DESCRIPTORS,
|
263
|
-
errors: Google::Gax::Grpc::API_ERRORS,
|
264
|
-
metadata: headers
|
265
|
-
)
|
266
|
-
end
|
267
|
-
|
268
|
-
# Allow overriding the service path/port in subclasses.
|
269
|
-
service_path = service_address || self.class::SERVICE_ADDRESS
|
270
|
-
port = service_port || self.class::DEFAULT_SERVICE_PORT
|
271
|
-
interceptors = self.class::GRPC_INTERCEPTORS
|
272
|
-
@intents_stub = Google::Gax::Grpc.create_stub(
|
273
|
-
service_path,
|
274
|
-
port,
|
275
|
-
chan_creds: chan_creds,
|
276
|
-
channel: channel,
|
277
|
-
updater_proc: updater_proc,
|
278
|
-
scopes: scopes,
|
279
|
-
interceptors: interceptors,
|
280
|
-
&Google::Cloud::Dialogflow::V2::Intents::Stub.method(:new)
|
281
|
-
)
|
282
|
-
|
283
|
-
@list_intents = Google::Gax.create_api_call(
|
284
|
-
@intents_stub.method(:list_intents),
|
285
|
-
defaults["list_intents"],
|
286
|
-
exception_transformer: exception_transformer,
|
287
|
-
params_extractor: proc do |request|
|
288
|
-
{'parent' => request.parent}
|
289
|
-
end
|
290
|
-
)
|
291
|
-
@get_intent = Google::Gax.create_api_call(
|
292
|
-
@intents_stub.method(:get_intent),
|
293
|
-
defaults["get_intent"],
|
294
|
-
exception_transformer: exception_transformer,
|
295
|
-
params_extractor: proc do |request|
|
296
|
-
{'name' => request.name}
|
297
|
-
end
|
298
|
-
)
|
299
|
-
@create_intent = Google::Gax.create_api_call(
|
300
|
-
@intents_stub.method(:create_intent),
|
301
|
-
defaults["create_intent"],
|
302
|
-
exception_transformer: exception_transformer,
|
303
|
-
params_extractor: proc do |request|
|
304
|
-
{'parent' => request.parent}
|
305
|
-
end
|
306
|
-
)
|
307
|
-
@update_intent = Google::Gax.create_api_call(
|
308
|
-
@intents_stub.method(:update_intent),
|
309
|
-
defaults["update_intent"],
|
310
|
-
exception_transformer: exception_transformer,
|
311
|
-
params_extractor: proc do |request|
|
312
|
-
{'intent.name' => request.intent.name}
|
313
|
-
end
|
314
|
-
)
|
315
|
-
@delete_intent = Google::Gax.create_api_call(
|
316
|
-
@intents_stub.method(:delete_intent),
|
317
|
-
defaults["delete_intent"],
|
318
|
-
exception_transformer: exception_transformer,
|
319
|
-
params_extractor: proc do |request|
|
320
|
-
{'name' => request.name}
|
321
|
-
end
|
322
|
-
)
|
323
|
-
@batch_update_intents = Google::Gax.create_api_call(
|
324
|
-
@intents_stub.method(:batch_update_intents),
|
325
|
-
defaults["batch_update_intents"],
|
326
|
-
exception_transformer: exception_transformer,
|
327
|
-
params_extractor: proc do |request|
|
328
|
-
{'parent' => request.parent}
|
329
|
-
end
|
330
|
-
)
|
331
|
-
@batch_delete_intents = Google::Gax.create_api_call(
|
332
|
-
@intents_stub.method(:batch_delete_intents),
|
333
|
-
defaults["batch_delete_intents"],
|
334
|
-
exception_transformer: exception_transformer,
|
335
|
-
params_extractor: proc do |request|
|
336
|
-
{'parent' => request.parent}
|
337
|
-
end
|
338
|
-
)
|
339
|
-
end
|
340
|
-
|
341
|
-
# Service calls
|
342
|
-
|
343
|
-
# Returns the list of all intents in the specified agent.
|
344
|
-
#
|
345
|
-
# @param parent [String]
|
346
|
-
# Required. The agent to list all intents from.
|
347
|
-
# Format: `projects/<Project ID>/agent`.
|
348
|
-
# @param language_code [String]
|
349
|
-
# Optional. The language to list training phrases, parameters and rich
|
350
|
-
# messages for. If not specified, the agent's default language is used.
|
351
|
-
# [Many
|
352
|
-
# languages](https://cloud.google.com/dialogflow/docs/reference/language)
|
353
|
-
# are supported. Note: languages must be enabled in the agent before they can
|
354
|
-
# be used.
|
355
|
-
# @param intent_view [Google::Cloud::Dialogflow::V2::IntentView]
|
356
|
-
# Optional. The resource view to apply to the returned intent.
|
357
|
-
# @param page_size [Integer]
|
358
|
-
# The maximum number of resources contained in the underlying API
|
359
|
-
# response. If page streaming is performed per-resource, this
|
360
|
-
# parameter does not affect the return value. If page streaming is
|
361
|
-
# performed per-page, this determines the maximum number of
|
362
|
-
# resources in a page.
|
363
|
-
# @param options [Google::Gax::CallOptions]
|
364
|
-
# Overrides the default settings for this call, e.g, timeout,
|
365
|
-
# retries, etc.
|
366
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
367
|
-
# @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Dialogflow::V2::Intent>]
|
368
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
369
|
-
# @return [Google::Gax::PagedEnumerable<Google::Cloud::Dialogflow::V2::Intent>]
|
370
|
-
# An enumerable of Google::Cloud::Dialogflow::V2::Intent instances.
|
371
|
-
# See Google::Gax::PagedEnumerable documentation for other
|
372
|
-
# operations such as per-page iteration or access to the response
|
373
|
-
# object.
|
374
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
375
|
-
# @example
|
376
|
-
# require "google/cloud/dialogflow"
|
377
|
-
#
|
378
|
-
# intents_client = Google::Cloud::Dialogflow::Intents.new(version: :v2)
|
379
|
-
# formatted_parent = Google::Cloud::Dialogflow::V2::IntentsClient.project_agent_path("[PROJECT]")
|
380
|
-
#
|
381
|
-
# # Iterate over all results.
|
382
|
-
# intents_client.list_intents(formatted_parent).each do |element|
|
383
|
-
# # Process element.
|
384
|
-
# end
|
385
|
-
#
|
386
|
-
# # Or iterate over results one page at a time.
|
387
|
-
# intents_client.list_intents(formatted_parent).each_page do |page|
|
388
|
-
# # Process each page at a time.
|
389
|
-
# page.each do |element|
|
390
|
-
# # Process element.
|
391
|
-
# end
|
392
|
-
# end
|
393
|
-
|
394
|
-
def list_intents \
|
395
|
-
parent,
|
396
|
-
language_code: nil,
|
397
|
-
intent_view: nil,
|
398
|
-
page_size: nil,
|
399
|
-
options: nil,
|
400
|
-
&block
|
401
|
-
req = {
|
402
|
-
parent: parent,
|
403
|
-
language_code: language_code,
|
404
|
-
intent_view: intent_view,
|
405
|
-
page_size: page_size
|
406
|
-
}.delete_if { |_, v| v.nil? }
|
407
|
-
req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::ListIntentsRequest)
|
408
|
-
@list_intents.call(req, options, &block)
|
409
|
-
end
|
410
|
-
|
411
|
-
# Retrieves the specified intent.
|
412
|
-
#
|
413
|
-
# @param name [String]
|
414
|
-
# Required. The name of the intent.
|
415
|
-
# Format: `projects/<Project ID>/agent/intents/<Intent ID>`.
|
416
|
-
# @param language_code [String]
|
417
|
-
# Optional. The language to retrieve training phrases, parameters and rich
|
418
|
-
# messages for. If not specified, the agent's default language is used.
|
419
|
-
# [Many
|
420
|
-
# languages](https://cloud.google.com/dialogflow/docs/reference/language)
|
421
|
-
# are supported. Note: languages must be enabled in the agent before they can
|
422
|
-
# be used.
|
423
|
-
# @param intent_view [Google::Cloud::Dialogflow::V2::IntentView]
|
424
|
-
# Optional. The resource view to apply to the returned intent.
|
425
|
-
# @param options [Google::Gax::CallOptions]
|
426
|
-
# Overrides the default settings for this call, e.g, timeout,
|
427
|
-
# retries, etc.
|
428
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
429
|
-
# @yieldparam result [Google::Cloud::Dialogflow::V2::Intent]
|
430
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
431
|
-
# @return [Google::Cloud::Dialogflow::V2::Intent]
|
432
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
433
|
-
# @example
|
434
|
-
# require "google/cloud/dialogflow"
|
435
|
-
#
|
436
|
-
# intents_client = Google::Cloud::Dialogflow::Intents.new(version: :v2)
|
437
|
-
# formatted_name = Google::Cloud::Dialogflow::V2::IntentsClient.intent_path("[PROJECT]", "[INTENT]")
|
438
|
-
# response = intents_client.get_intent(formatted_name)
|
439
|
-
|
440
|
-
def get_intent \
|
441
|
-
name,
|
442
|
-
language_code: nil,
|
443
|
-
intent_view: nil,
|
444
|
-
options: nil,
|
445
|
-
&block
|
446
|
-
req = {
|
447
|
-
name: name,
|
448
|
-
language_code: language_code,
|
449
|
-
intent_view: intent_view
|
450
|
-
}.delete_if { |_, v| v.nil? }
|
451
|
-
req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::GetIntentRequest)
|
452
|
-
@get_intent.call(req, options, &block)
|
453
|
-
end
|
454
|
-
|
455
|
-
# Creates an intent in the specified agent.
|
456
|
-
#
|
457
|
-
# @param parent [String]
|
458
|
-
# Required. The agent to create a intent for.
|
459
|
-
# Format: `projects/<Project ID>/agent`.
|
460
|
-
# @param intent [Google::Cloud::Dialogflow::V2::Intent | Hash]
|
461
|
-
# Required. The intent to create.
|
462
|
-
# A hash of the same form as `Google::Cloud::Dialogflow::V2::Intent`
|
463
|
-
# can also be provided.
|
464
|
-
# @param language_code [String]
|
465
|
-
# Optional. The language of training phrases, parameters and rich messages
|
466
|
-
# defined in `intent`. If not specified, the agent's default language is
|
467
|
-
# used. [Many
|
468
|
-
# languages](https://cloud.google.com/dialogflow/docs/reference/language)
|
469
|
-
# are supported. Note: languages must be enabled in the agent before they can
|
470
|
-
# be used.
|
471
|
-
# @param intent_view [Google::Cloud::Dialogflow::V2::IntentView]
|
472
|
-
# Optional. The resource view to apply to the returned intent.
|
473
|
-
# @param options [Google::Gax::CallOptions]
|
474
|
-
# Overrides the default settings for this call, e.g, timeout,
|
475
|
-
# retries, etc.
|
476
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
477
|
-
# @yieldparam result [Google::Cloud::Dialogflow::V2::Intent]
|
478
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
479
|
-
# @return [Google::Cloud::Dialogflow::V2::Intent]
|
480
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
481
|
-
# @example
|
482
|
-
# require "google/cloud/dialogflow"
|
483
|
-
#
|
484
|
-
# intents_client = Google::Cloud::Dialogflow::Intents.new(version: :v2)
|
485
|
-
# formatted_parent = Google::Cloud::Dialogflow::V2::IntentsClient.project_agent_path("[PROJECT]")
|
486
|
-
#
|
487
|
-
# # TODO: Initialize `intent`:
|
488
|
-
# intent = {}
|
489
|
-
# response = intents_client.create_intent(formatted_parent, intent)
|
490
|
-
|
491
|
-
def create_intent \
|
492
|
-
parent,
|
493
|
-
intent,
|
494
|
-
language_code: nil,
|
495
|
-
intent_view: nil,
|
496
|
-
options: nil,
|
497
|
-
&block
|
498
|
-
req = {
|
499
|
-
parent: parent,
|
500
|
-
intent: intent,
|
501
|
-
language_code: language_code,
|
502
|
-
intent_view: intent_view
|
503
|
-
}.delete_if { |_, v| v.nil? }
|
504
|
-
req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::CreateIntentRequest)
|
505
|
-
@create_intent.call(req, options, &block)
|
506
|
-
end
|
507
|
-
|
508
|
-
# Updates the specified intent.
|
509
|
-
#
|
510
|
-
# @param intent [Google::Cloud::Dialogflow::V2::Intent | Hash]
|
511
|
-
# Required. The intent to update.
|
512
|
-
# A hash of the same form as `Google::Cloud::Dialogflow::V2::Intent`
|
513
|
-
# can also be provided.
|
514
|
-
# @param language_code [String]
|
515
|
-
# Optional. The language of training phrases, parameters and rich messages
|
516
|
-
# defined in `intent`. If not specified, the agent's default language is
|
517
|
-
# used. [Many
|
518
|
-
# languages](https://cloud.google.com/dialogflow/docs/reference/language)
|
519
|
-
# are supported. Note: languages must be enabled in the agent before they can
|
520
|
-
# be used.
|
521
|
-
# @param update_mask [Google::Protobuf::FieldMask | Hash]
|
522
|
-
# Optional. The mask to control which fields get updated.
|
523
|
-
# A hash of the same form as `Google::Protobuf::FieldMask`
|
524
|
-
# can also be provided.
|
525
|
-
# @param intent_view [Google::Cloud::Dialogflow::V2::IntentView]
|
526
|
-
# Optional. The resource view to apply to the returned intent.
|
527
|
-
# @param options [Google::Gax::CallOptions]
|
528
|
-
# Overrides the default settings for this call, e.g, timeout,
|
529
|
-
# retries, etc.
|
530
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
531
|
-
# @yieldparam result [Google::Cloud::Dialogflow::V2::Intent]
|
532
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
533
|
-
# @return [Google::Cloud::Dialogflow::V2::Intent]
|
534
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
535
|
-
# @example
|
536
|
-
# require "google/cloud/dialogflow"
|
537
|
-
#
|
538
|
-
# intents_client = Google::Cloud::Dialogflow::Intents.new(version: :v2)
|
539
|
-
#
|
540
|
-
# # TODO: Initialize `intent`:
|
541
|
-
# intent = {}
|
542
|
-
# response = intents_client.update_intent(intent)
|
543
|
-
|
544
|
-
def update_intent \
|
545
|
-
intent,
|
546
|
-
language_code: nil,
|
547
|
-
update_mask: nil,
|
548
|
-
intent_view: nil,
|
549
|
-
options: nil,
|
550
|
-
&block
|
551
|
-
req = {
|
552
|
-
intent: intent,
|
553
|
-
language_code: language_code,
|
554
|
-
update_mask: update_mask,
|
555
|
-
intent_view: intent_view
|
556
|
-
}.delete_if { |_, v| v.nil? }
|
557
|
-
req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::UpdateIntentRequest)
|
558
|
-
@update_intent.call(req, options, &block)
|
559
|
-
end
|
560
|
-
|
561
|
-
# Deletes the specified intent and its direct or indirect followup intents.
|
562
|
-
#
|
563
|
-
# @param name [String]
|
564
|
-
# Required. The name of the intent to delete. If this intent has direct or
|
565
|
-
# indirect followup intents, we also delete them.
|
566
|
-
# Format: `projects/<Project ID>/agent/intents/<Intent ID>`.
|
567
|
-
# @param options [Google::Gax::CallOptions]
|
568
|
-
# Overrides the default settings for this call, e.g, timeout,
|
569
|
-
# retries, etc.
|
570
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
571
|
-
# @yieldparam result []
|
572
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
573
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
574
|
-
# @example
|
575
|
-
# require "google/cloud/dialogflow"
|
576
|
-
#
|
577
|
-
# intents_client = Google::Cloud::Dialogflow::Intents.new(version: :v2)
|
578
|
-
# formatted_name = Google::Cloud::Dialogflow::V2::IntentsClient.intent_path("[PROJECT]", "[INTENT]")
|
579
|
-
# intents_client.delete_intent(formatted_name)
|
580
|
-
|
581
|
-
def delete_intent \
|
582
|
-
name,
|
583
|
-
options: nil,
|
584
|
-
&block
|
585
|
-
req = {
|
586
|
-
name: name
|
587
|
-
}.delete_if { |_, v| v.nil? }
|
588
|
-
req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::DeleteIntentRequest)
|
589
|
-
@delete_intent.call(req, options, &block)
|
590
|
-
nil
|
591
|
-
end
|
592
|
-
|
593
|
-
# Updates/Creates multiple intents in the specified agent.
|
594
|
-
#
|
595
|
-
# Operation <response: {Google::Cloud::Dialogflow::V2::BatchUpdateIntentsResponse BatchUpdateIntentsResponse}>
|
596
|
-
#
|
597
|
-
# @param parent [String]
|
598
|
-
# Required. The name of the agent to update or create intents in.
|
599
|
-
# Format: `projects/<Project ID>/agent`.
|
600
|
-
# @param intent_batch_uri [String]
|
601
|
-
# The URI to a Google Cloud Storage file containing intents to update or
|
602
|
-
# create. The file format can either be a serialized proto (of IntentBatch
|
603
|
-
# type) or JSON object. Note: The URI must start with "gs://".
|
604
|
-
# @param intent_batch_inline [Google::Cloud::Dialogflow::V2::IntentBatch | Hash]
|
605
|
-
# The collection of intents to update or create.
|
606
|
-
# A hash of the same form as `Google::Cloud::Dialogflow::V2::IntentBatch`
|
607
|
-
# can also be provided.
|
608
|
-
# @param language_code [String]
|
609
|
-
# Optional. The language of training phrases, parameters and rich messages
|
610
|
-
# defined in `intents`. If not specified, the agent's default language is
|
611
|
-
# used. [Many
|
612
|
-
# languages](https://cloud.google.com/dialogflow/docs/reference/language)
|
613
|
-
# are supported. Note: languages must be enabled in the agent before they can
|
614
|
-
# be used.
|
615
|
-
# @param update_mask [Google::Protobuf::FieldMask | Hash]
|
616
|
-
# Optional. The mask to control which fields get updated.
|
617
|
-
# A hash of the same form as `Google::Protobuf::FieldMask`
|
618
|
-
# can also be provided.
|
619
|
-
# @param intent_view [Google::Cloud::Dialogflow::V2::IntentView]
|
620
|
-
# Optional. The resource view to apply to the returned intent.
|
621
|
-
# @param options [Google::Gax::CallOptions]
|
622
|
-
# Overrides the default settings for this call, e.g, timeout,
|
623
|
-
# retries, etc.
|
624
|
-
# @return [Google::Gax::Operation]
|
625
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
626
|
-
# @example
|
627
|
-
# require "google/cloud/dialogflow"
|
628
|
-
#
|
629
|
-
# intents_client = Google::Cloud::Dialogflow::Intents.new(version: :v2)
|
630
|
-
# formatted_parent = Google::Cloud::Dialogflow::V2::IntentsClient.project_agent_path("[PROJECT]")
|
631
|
-
#
|
632
|
-
# # Register a callback during the method call.
|
633
|
-
# operation = intents_client.batch_update_intents(formatted_parent) do |op|
|
634
|
-
# raise op.results.message if op.error?
|
635
|
-
# op_results = op.results
|
636
|
-
# # Process the results.
|
637
|
-
#
|
638
|
-
# metadata = op.metadata
|
639
|
-
# # Process the metadata.
|
640
|
-
# end
|
641
|
-
#
|
642
|
-
# # Or use the return value to register a callback.
|
643
|
-
# operation.on_done do |op|
|
644
|
-
# raise op.results.message if op.error?
|
645
|
-
# op_results = op.results
|
646
|
-
# # Process the results.
|
647
|
-
#
|
648
|
-
# metadata = op.metadata
|
649
|
-
# # Process the metadata.
|
650
|
-
# end
|
651
|
-
#
|
652
|
-
# # Manually reload the operation.
|
653
|
-
# operation.reload!
|
654
|
-
#
|
655
|
-
# # Or block until the operation completes, triggering callbacks on
|
656
|
-
# # completion.
|
657
|
-
# operation.wait_until_done!
|
658
|
-
|
659
|
-
def batch_update_intents \
|
660
|
-
parent,
|
661
|
-
intent_batch_uri: nil,
|
662
|
-
intent_batch_inline: nil,
|
663
|
-
language_code: nil,
|
664
|
-
update_mask: nil,
|
665
|
-
intent_view: nil,
|
666
|
-
options: nil
|
667
|
-
req = {
|
668
|
-
parent: parent,
|
669
|
-
intent_batch_uri: intent_batch_uri,
|
670
|
-
intent_batch_inline: intent_batch_inline,
|
671
|
-
language_code: language_code,
|
672
|
-
update_mask: update_mask,
|
673
|
-
intent_view: intent_view
|
674
|
-
}.delete_if { |_, v| v.nil? }
|
675
|
-
req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::BatchUpdateIntentsRequest)
|
676
|
-
operation = Google::Gax::Operation.new(
|
677
|
-
@batch_update_intents.call(req, options),
|
678
|
-
@operations_client,
|
679
|
-
Google::Cloud::Dialogflow::V2::BatchUpdateIntentsResponse,
|
680
|
-
Google::Protobuf::Struct,
|
681
|
-
call_options: options
|
682
|
-
)
|
683
|
-
operation.on_done { |operation| yield(operation) } if block_given?
|
684
|
-
operation
|
685
|
-
end
|
686
|
-
|
687
|
-
# Deletes intents in the specified agent.
|
688
|
-
#
|
689
|
-
# Operation <response: {Google::Protobuf::Empty}>
|
690
|
-
#
|
691
|
-
# @param parent [String]
|
692
|
-
# Required. The name of the agent to delete all entities types for. Format:
|
693
|
-
# `projects/<Project ID>/agent`.
|
694
|
-
# @param intents [Array<Google::Cloud::Dialogflow::V2::Intent | Hash>]
|
695
|
-
# Required. The collection of intents to delete. Only intent `name` must be
|
696
|
-
# filled in.
|
697
|
-
# A hash of the same form as `Google::Cloud::Dialogflow::V2::Intent`
|
698
|
-
# can also be provided.
|
699
|
-
# @param options [Google::Gax::CallOptions]
|
700
|
-
# Overrides the default settings for this call, e.g, timeout,
|
701
|
-
# retries, etc.
|
702
|
-
# @return [Google::Gax::Operation]
|
703
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
704
|
-
# @example
|
705
|
-
# require "google/cloud/dialogflow"
|
706
|
-
#
|
707
|
-
# intents_client = Google::Cloud::Dialogflow::Intents.new(version: :v2)
|
708
|
-
# formatted_parent = Google::Cloud::Dialogflow::V2::IntentsClient.project_agent_path("[PROJECT]")
|
709
|
-
#
|
710
|
-
# # TODO: Initialize `intents`:
|
711
|
-
# intents = []
|
712
|
-
#
|
713
|
-
# # Register a callback during the method call.
|
714
|
-
# operation = intents_client.batch_delete_intents(formatted_parent, intents) do |op|
|
715
|
-
# raise op.results.message if op.error?
|
716
|
-
# op_results = op.results
|
717
|
-
# # Process the results.
|
718
|
-
#
|
719
|
-
# metadata = op.metadata
|
720
|
-
# # Process the metadata.
|
721
|
-
# end
|
722
|
-
#
|
723
|
-
# # Or use the return value to register a callback.
|
724
|
-
# operation.on_done do |op|
|
725
|
-
# raise op.results.message if op.error?
|
726
|
-
# op_results = op.results
|
727
|
-
# # Process the results.
|
728
|
-
#
|
729
|
-
# metadata = op.metadata
|
730
|
-
# # Process the metadata.
|
731
|
-
# end
|
732
|
-
#
|
733
|
-
# # Manually reload the operation.
|
734
|
-
# operation.reload!
|
735
|
-
#
|
736
|
-
# # Or block until the operation completes, triggering callbacks on
|
737
|
-
# # completion.
|
738
|
-
# operation.wait_until_done!
|
739
|
-
|
740
|
-
def batch_delete_intents \
|
741
|
-
parent,
|
742
|
-
intents,
|
743
|
-
options: nil
|
744
|
-
req = {
|
745
|
-
parent: parent,
|
746
|
-
intents: intents
|
747
|
-
}.delete_if { |_, v| v.nil? }
|
748
|
-
req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::BatchDeleteIntentsRequest)
|
749
|
-
operation = Google::Gax::Operation.new(
|
750
|
-
@batch_delete_intents.call(req, options),
|
751
|
-
@operations_client,
|
752
|
-
Google::Protobuf::Empty,
|
753
|
-
Google::Protobuf::Struct,
|
754
|
-
call_options: options
|
755
|
-
)
|
756
|
-
operation.on_done { |operation| yield(operation) } if block_given?
|
757
|
-
operation
|
758
|
-
end
|
759
|
-
end
|
760
|
-
end
|
761
|
-
end
|
762
|
-
end
|
763
|
-
end
|