google-cloud-dialogflow-v2 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +169 -0
  4. data/LICENSE.md +201 -0
  5. data/README.md +24 -0
  6. data/lib/google-cloud-dialogflow-v2.rb +1 -0
  7. data/lib/google/cloud/common_resources_pb.rb +15 -0
  8. data/lib/google/cloud/dialogflow/v2.rb +24 -0
  9. data/lib/google/cloud/dialogflow/v2/agent_pb.rb +122 -0
  10. data/lib/google/cloud/dialogflow/v2/agent_services_pb.rb +110 -0
  11. data/lib/google/cloud/dialogflow/v2/agents.rb +21 -0
  12. data/lib/google/cloud/dialogflow/v2/agents/client.rb +1047 -0
  13. data/lib/google/cloud/dialogflow/v2/agents/credentials.rb +53 -0
  14. data/lib/google/cloud/dialogflow/v2/agents/operations.rb +559 -0
  15. data/lib/google/cloud/dialogflow/v2/agents/paths.rb +59 -0
  16. data/lib/google/cloud/dialogflow/v2/audio_config_pb.rb +97 -0
  17. data/lib/google/cloud/dialogflow/v2/context_pb.rb +64 -0
  18. data/lib/google/cloud/dialogflow/v2/context_services_pb.rb +74 -0
  19. data/lib/google/cloud/dialogflow/v2/contexts.rb +20 -0
  20. data/lib/google/cloud/dialogflow/v2/contexts/client.rb +756 -0
  21. data/lib/google/cloud/dialogflow/v2/contexts/credentials.rb +53 -0
  22. data/lib/google/cloud/dialogflow/v2/contexts/paths.rb +50 -0
  23. data/lib/google/cloud/dialogflow/v2/entity_type_pb.rb +126 -0
  24. data/lib/google/cloud/dialogflow/v2/entity_type_services_pb.rb +104 -0
  25. data/lib/google/cloud/dialogflow/v2/entity_types.rb +21 -0
  26. data/lib/google/cloud/dialogflow/v2/entity_types/client.rb +1150 -0
  27. data/lib/google/cloud/dialogflow/v2/entity_types/credentials.rb +53 -0
  28. data/lib/google/cloud/dialogflow/v2/entity_types/operations.rb +559 -0
  29. data/lib/google/cloud/dialogflow/v2/entity_types/paths.rb +62 -0
  30. data/lib/google/cloud/dialogflow/v2/intent_pb.rb +368 -0
  31. data/lib/google/cloud/dialogflow/v2/intent_services_pb.rb +92 -0
  32. data/lib/google/cloud/dialogflow/v2/intents.rb +21 -0
  33. data/lib/google/cloud/dialogflow/v2/intents/client.rb +893 -0
  34. data/lib/google/cloud/dialogflow/v2/intents/credentials.rb +53 -0
  35. data/lib/google/cloud/dialogflow/v2/intents/operations.rb +559 -0
  36. data/lib/google/cloud/dialogflow/v2/intents/paths.rb +81 -0
  37. data/lib/google/cloud/dialogflow/v2/session_entity_type_pb.rb +66 -0
  38. data/lib/google/cloud/dialogflow/v2/session_entity_type_services_pb.rb +92 -0
  39. data/lib/google/cloud/dialogflow/v2/session_entity_types.rb +20 -0
  40. data/lib/google/cloud/dialogflow/v2/session_entity_types/client.rb +727 -0
  41. data/lib/google/cloud/dialogflow/v2/session_entity_types/credentials.rb +53 -0
  42. data/lib/google/cloud/dialogflow/v2/session_entity_types/paths.rb +69 -0
  43. data/lib/google/cloud/dialogflow/v2/session_pb.rb +142 -0
  44. data/lib/google/cloud/dialogflow/v2/session_services_pb.rb +55 -0
  45. data/lib/google/cloud/dialogflow/v2/sessions.rb +20 -0
  46. data/lib/google/cloud/dialogflow/v2/sessions/client.rb +472 -0
  47. data/lib/google/cloud/dialogflow/v2/sessions/credentials.rb +53 -0
  48. data/lib/google/cloud/dialogflow/v2/sessions/paths.rb +110 -0
  49. data/lib/google/cloud/dialogflow/v2/validation_result_pb.rb +37 -0
  50. data/lib/google/cloud/dialogflow/v2/version.rb +28 -0
  51. data/lib/google/cloud/dialogflow/v2/webhook_pb.rb +47 -0
  52. data/proto_docs/README.md +4 -0
  53. data/proto_docs/google/api/field_behavior.rb +59 -0
  54. data/proto_docs/google/api/resource.rb +247 -0
  55. data/proto_docs/google/cloud/dialogflow/v2/agent.rb +287 -0
  56. data/proto_docs/google/cloud/dialogflow/v2/audio_config.rb +363 -0
  57. data/proto_docs/google/cloud/dialogflow/v2/context.rb +144 -0
  58. data/proto_docs/google/cloud/dialogflow/v2/entity_type.rb +354 -0
  59. data/proto_docs/google/cloud/dialogflow/v2/intent.rb +1070 -0
  60. data/proto_docs/google/cloud/dialogflow/v2/session.rb +541 -0
  61. data/proto_docs/google/cloud/dialogflow/v2/session_entity_type.rb +155 -0
  62. data/proto_docs/google/cloud/dialogflow/v2/validation_result.rb +81 -0
  63. data/proto_docs/google/cloud/dialogflow/v2/webhook.rb +153 -0
  64. data/proto_docs/google/longrunning/operations.rb +150 -0
  65. data/proto_docs/google/protobuf/any.rb +137 -0
  66. data/proto_docs/google/protobuf/duration.rb +98 -0
  67. data/proto_docs/google/protobuf/empty.rb +36 -0
  68. data/proto_docs/google/protobuf/field_mask.rb +237 -0
  69. data/proto_docs/google/protobuf/struct.rb +96 -0
  70. data/proto_docs/google/rpc/status.rb +46 -0
  71. data/proto_docs/google/type/latlng.rb +38 -0
  72. metadata +225 -0
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/dialogflow/v2/intents/client"
20
+ require "google/cloud/dialogflow/v2/intents/operations"
21
+ require "google/cloud/dialogflow/v2/intents/credentials"
@@ -0,0 +1,893 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/errors"
24
+ require "google/cloud/dialogflow/v2/version"
25
+ require "google/cloud/dialogflow/v2/intent_pb"
26
+ require "google/cloud/dialogflow/v2/intents/credentials"
27
+ require "google/cloud/dialogflow/v2/intents/paths"
28
+ require "google/cloud/dialogflow/v2/intents/operations"
29
+
30
+
31
+ module Google
32
+ module Cloud
33
+ module Dialogflow
34
+ module V2
35
+ module Intents
36
+ # Service that implements Intents API.
37
+ class Client
38
+ include Paths
39
+
40
+ # @private
41
+ attr_reader :intents_stub
42
+
43
+ ##
44
+ # Configure the Intents Client class.
45
+ #
46
+ # See {Google::Cloud::Dialogflow::V2::Intents::Client::Configuration}
47
+ # for a description of the configuration fields.
48
+ #
49
+ # ## Example
50
+ #
51
+ # To modify the configuration for all Intents clients:
52
+ #
53
+ # Google::Cloud::Dialogflow::V2::Intents::Client.configure do |config|
54
+ # config.timeout = 10_000
55
+ # end
56
+ #
57
+ # @yield [config] Configure the Client client.
58
+ # @yieldparam config [Client::Configuration]
59
+ #
60
+ # @return [Client::Configuration]
61
+ #
62
+ def self.configure
63
+ @configure ||= begin
64
+ namespace = ["Google", "Cloud", "Dialogflow", "V2"]
65
+ parent_config = while namespace.any?
66
+ parent_name = namespace.join "::"
67
+ parent_const = const_get parent_name
68
+ break parent_const.configure if parent_const&.respond_to? :configure
69
+ namespace.pop
70
+ end
71
+ default_config = Client::Configuration.new parent_config
72
+
73
+ default_config.rpcs.list_intents.timeout = 60.0
74
+ default_config.rpcs.list_intents.retry_policy = {
75
+ initial_delay: 0.1,
76
+ max_delay: 60.0,
77
+ multiplier: 1.3,
78
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
79
+ }
80
+
81
+ default_config.rpcs.get_intent.timeout = 60.0
82
+ default_config.rpcs.get_intent.retry_policy = {
83
+ initial_delay: 0.1,
84
+ max_delay: 60.0,
85
+ multiplier: 1.3,
86
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
87
+ }
88
+
89
+ default_config.rpcs.create_intent.timeout = 60.0
90
+
91
+ default_config.rpcs.update_intent.timeout = 60.0
92
+
93
+ default_config.rpcs.delete_intent.timeout = 60.0
94
+ default_config.rpcs.delete_intent.retry_policy = {
95
+ initial_delay: 0.1,
96
+ max_delay: 60.0,
97
+ multiplier: 1.3,
98
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
99
+ }
100
+
101
+ default_config.rpcs.batch_update_intents.timeout = 60.0
102
+
103
+ default_config.rpcs.batch_delete_intents.timeout = 60.0
104
+ default_config.rpcs.batch_delete_intents.retry_policy = {
105
+ initial_delay: 0.1,
106
+ max_delay: 60.0,
107
+ multiplier: 1.3,
108
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
109
+ }
110
+
111
+ default_config
112
+ end
113
+ yield @configure if block_given?
114
+ @configure
115
+ end
116
+
117
+ ##
118
+ # Configure the Intents Client instance.
119
+ #
120
+ # The configuration is set to the derived mode, meaning that values can be changed,
121
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
122
+ # should be made on {Client.configure}.
123
+ #
124
+ # See {Google::Cloud::Dialogflow::V2::Intents::Client::Configuration}
125
+ # for a description of the configuration fields.
126
+ #
127
+ # @yield [config] Configure the Client client.
128
+ # @yieldparam config [Client::Configuration]
129
+ #
130
+ # @return [Client::Configuration]
131
+ #
132
+ def configure
133
+ yield @config if block_given?
134
+ @config
135
+ end
136
+
137
+ ##
138
+ # Create a new Intents client object.
139
+ #
140
+ # ## Examples
141
+ #
142
+ # To create a new Intents client with the default
143
+ # configuration:
144
+ #
145
+ # client = Google::Cloud::Dialogflow::V2::Intents::Client.new
146
+ #
147
+ # To create a new Intents client with a custom
148
+ # configuration:
149
+ #
150
+ # client = Google::Cloud::Dialogflow::V2::Intents::Client.new do |config|
151
+ # config.timeout = 10_000
152
+ # end
153
+ #
154
+ # @yield [config] Configure the Intents client.
155
+ # @yieldparam config [Client::Configuration]
156
+ #
157
+ def initialize
158
+ # These require statements are intentionally placed here to initialize
159
+ # the gRPC module only when it's required.
160
+ # See https://github.com/googleapis/toolkit/issues/446
161
+ require "gapic/grpc"
162
+ require "google/cloud/dialogflow/v2/intent_services_pb"
163
+
164
+ # Create the configuration object
165
+ @config = Configuration.new Client.configure
166
+
167
+ # Yield the configuration if needed
168
+ yield @config if block_given?
169
+
170
+ # Create credentials
171
+ credentials = @config.credentials
172
+ credentials ||= Credentials.default scope: @config.scope
173
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
174
+ credentials = Credentials.new credentials, scope: @config.scope
175
+ end
176
+ @quota_project_id = credentials.respond_to?(:quota_project_id) ? credentials.quota_project_id : nil
177
+
178
+ @operations_client = Operations.new do |config|
179
+ config.credentials = credentials
180
+ end
181
+
182
+ @intents_stub = Gapic::ServiceStub.new(
183
+ Google::Cloud::Dialogflow::V2::Intents::Stub,
184
+ credentials: credentials,
185
+ endpoint: @config.endpoint,
186
+ channel_args: @config.channel_args,
187
+ interceptors: @config.interceptors
188
+ )
189
+ end
190
+
191
+ # Service calls
192
+
193
+ ##
194
+ # Returns the list of all intents in the specified agent.
195
+ #
196
+ # @overload list_intents(request, options = nil)
197
+ # @param request [Google::Cloud::Dialogflow::V2::ListIntentsRequest | Hash]
198
+ # Returns the list of all intents in the specified agent.
199
+ # @param options [Gapic::CallOptions, Hash]
200
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
201
+ #
202
+ # @overload list_intents(parent: nil, language_code: nil, intent_view: nil, page_size: nil, page_token: nil)
203
+ # @param parent [String]
204
+ # Required. The agent to list all intents from.
205
+ # Format: `projects/<Project ID>/agent`.
206
+ # @param language_code [String]
207
+ # Optional. The language to list training phrases, parameters and rich
208
+ # messages for. If not specified, the agent's default language is used.
209
+ # [Many
210
+ # languages](https://cloud.google.com/dialogflow/docs/reference/language)
211
+ # are supported. Note: languages must be enabled in the agent before they can
212
+ # be used.
213
+ # @param intent_view [Google::Cloud::Dialogflow::V2::IntentView]
214
+ # Optional. The resource view to apply to the returned intent.
215
+ # @param page_size [Integer]
216
+ # Optional. The maximum number of items to return in a single page. By
217
+ # default 100 and at most 1000.
218
+ # @param page_token [String]
219
+ # Optional. The next_page_token value returned from a previous list request.
220
+ #
221
+ #
222
+ # @yield [response, operation] Access the result along with the RPC operation
223
+ # @yieldparam response [Gapic::PagedEnumerable<Google::Cloud::Dialogflow::V2::Intent>]
224
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
225
+ #
226
+ # @return [Gapic::PagedEnumerable<Google::Cloud::Dialogflow::V2::Intent>]
227
+ #
228
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
229
+ #
230
+ def list_intents request, options = nil
231
+ raise ArgumentError, "request must be provided" if request.nil?
232
+
233
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Dialogflow::V2::ListIntentsRequest
234
+
235
+ # Converts hash and nil to an options object
236
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
237
+
238
+ # Customize the options with defaults
239
+ metadata = @config.rpcs.list_intents.metadata.to_h
240
+
241
+ # Set x-goog-api-client and x-goog-user-project headers
242
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
243
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
244
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
245
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
246
+
247
+ header_params = {
248
+ "parent" => request.parent
249
+ }
250
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
251
+ metadata[:"x-goog-request-params"] ||= request_params_header
252
+
253
+ options.apply_defaults timeout: @config.rpcs.list_intents.timeout,
254
+ metadata: metadata,
255
+ retry_policy: @config.rpcs.list_intents.retry_policy
256
+ options.apply_defaults metadata: @config.metadata,
257
+ retry_policy: @config.retry_policy
258
+
259
+ @intents_stub.call_rpc :list_intents, request, options: options do |response, operation|
260
+ response = Gapic::PagedEnumerable.new @intents_stub, :list_intents, request, response, operation, options
261
+ yield response, operation if block_given?
262
+ return response
263
+ end
264
+ rescue GRPC::BadStatus => e
265
+ raise Google::Cloud::Error.from_error(e)
266
+ end
267
+
268
+ ##
269
+ # Retrieves the specified intent.
270
+ #
271
+ # @overload get_intent(request, options = nil)
272
+ # @param request [Google::Cloud::Dialogflow::V2::GetIntentRequest | Hash]
273
+ # Retrieves the specified intent.
274
+ # @param options [Gapic::CallOptions, Hash]
275
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
276
+ #
277
+ # @overload get_intent(name: nil, language_code: nil, intent_view: nil)
278
+ # @param name [String]
279
+ # Required. The name of the intent.
280
+ # Format: `projects/<Project ID>/agent/intents/<Intent ID>`.
281
+ # @param language_code [String]
282
+ # Optional. The language to retrieve training phrases, parameters and rich
283
+ # messages for. If not specified, the agent's default language is used.
284
+ # [Many
285
+ # languages](https://cloud.google.com/dialogflow/docs/reference/language)
286
+ # are supported. Note: languages must be enabled in the agent before they can
287
+ # be used.
288
+ # @param intent_view [Google::Cloud::Dialogflow::V2::IntentView]
289
+ # Optional. The resource view to apply to the returned intent.
290
+ #
291
+ #
292
+ # @yield [response, operation] Access the result along with the RPC operation
293
+ # @yieldparam response [Google::Cloud::Dialogflow::V2::Intent]
294
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
295
+ #
296
+ # @return [Google::Cloud::Dialogflow::V2::Intent]
297
+ #
298
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
299
+ #
300
+ def get_intent request, options = nil
301
+ raise ArgumentError, "request must be provided" if request.nil?
302
+
303
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Dialogflow::V2::GetIntentRequest
304
+
305
+ # Converts hash and nil to an options object
306
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
307
+
308
+ # Customize the options with defaults
309
+ metadata = @config.rpcs.get_intent.metadata.to_h
310
+
311
+ # Set x-goog-api-client and x-goog-user-project headers
312
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
313
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
314
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
315
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
316
+
317
+ header_params = {
318
+ "name" => request.name
319
+ }
320
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
321
+ metadata[:"x-goog-request-params"] ||= request_params_header
322
+
323
+ options.apply_defaults timeout: @config.rpcs.get_intent.timeout,
324
+ metadata: metadata,
325
+ retry_policy: @config.rpcs.get_intent.retry_policy
326
+ options.apply_defaults metadata: @config.metadata,
327
+ retry_policy: @config.retry_policy
328
+
329
+ @intents_stub.call_rpc :get_intent, request, options: options do |response, operation|
330
+ yield response, operation if block_given?
331
+ return response
332
+ end
333
+ rescue GRPC::BadStatus => e
334
+ raise Google::Cloud::Error.from_error(e)
335
+ end
336
+
337
+ ##
338
+ # Creates an intent in the specified agent.
339
+ #
340
+ # @overload create_intent(request, options = nil)
341
+ # @param request [Google::Cloud::Dialogflow::V2::CreateIntentRequest | Hash]
342
+ # Creates an intent in the specified agent.
343
+ # @param options [Gapic::CallOptions, Hash]
344
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
345
+ #
346
+ # @overload create_intent(parent: nil, intent: nil, language_code: nil, intent_view: nil)
347
+ # @param parent [String]
348
+ # Required. The agent to create a intent for.
349
+ # Format: `projects/<Project ID>/agent`.
350
+ # @param intent [Google::Cloud::Dialogflow::V2::Intent | Hash]
351
+ # Required. The intent to create.
352
+ # @param language_code [String]
353
+ # Optional. The language of training phrases, parameters and rich messages
354
+ # defined in `intent`. If not specified, the agent's default language is
355
+ # used. [Many
356
+ # languages](https://cloud.google.com/dialogflow/docs/reference/language)
357
+ # are supported. Note: languages must be enabled in the agent before they can
358
+ # be used.
359
+ # @param intent_view [Google::Cloud::Dialogflow::V2::IntentView]
360
+ # Optional. The resource view to apply to the returned intent.
361
+ #
362
+ #
363
+ # @yield [response, operation] Access the result along with the RPC operation
364
+ # @yieldparam response [Google::Cloud::Dialogflow::V2::Intent]
365
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
366
+ #
367
+ # @return [Google::Cloud::Dialogflow::V2::Intent]
368
+ #
369
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
370
+ #
371
+ def create_intent request, options = nil
372
+ raise ArgumentError, "request must be provided" if request.nil?
373
+
374
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Dialogflow::V2::CreateIntentRequest
375
+
376
+ # Converts hash and nil to an options object
377
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
378
+
379
+ # Customize the options with defaults
380
+ metadata = @config.rpcs.create_intent.metadata.to_h
381
+
382
+ # Set x-goog-api-client and x-goog-user-project headers
383
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
384
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
385
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
386
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
387
+
388
+ header_params = {
389
+ "parent" => request.parent
390
+ }
391
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
392
+ metadata[:"x-goog-request-params"] ||= request_params_header
393
+
394
+ options.apply_defaults timeout: @config.rpcs.create_intent.timeout,
395
+ metadata: metadata,
396
+ retry_policy: @config.rpcs.create_intent.retry_policy
397
+ options.apply_defaults metadata: @config.metadata,
398
+ retry_policy: @config.retry_policy
399
+
400
+ @intents_stub.call_rpc :create_intent, request, options: options do |response, operation|
401
+ yield response, operation if block_given?
402
+ return response
403
+ end
404
+ rescue GRPC::BadStatus => e
405
+ raise Google::Cloud::Error.from_error(e)
406
+ end
407
+
408
+ ##
409
+ # Updates the specified intent.
410
+ #
411
+ # @overload update_intent(request, options = nil)
412
+ # @param request [Google::Cloud::Dialogflow::V2::UpdateIntentRequest | Hash]
413
+ # Updates the specified intent.
414
+ # @param options [Gapic::CallOptions, Hash]
415
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
416
+ #
417
+ # @overload update_intent(intent: nil, language_code: nil, update_mask: nil, intent_view: nil)
418
+ # @param intent [Google::Cloud::Dialogflow::V2::Intent | Hash]
419
+ # Required. The intent to update.
420
+ # @param language_code [String]
421
+ # Optional. The language of training phrases, parameters and rich messages
422
+ # defined in `intent`. If not specified, the agent's default language is
423
+ # used. [Many
424
+ # languages](https://cloud.google.com/dialogflow/docs/reference/language)
425
+ # are supported. Note: languages must be enabled in the agent before they can
426
+ # be used.
427
+ # @param update_mask [Google::Protobuf::FieldMask | Hash]
428
+ # Optional. The mask to control which fields get updated.
429
+ # @param intent_view [Google::Cloud::Dialogflow::V2::IntentView]
430
+ # Optional. The resource view to apply to the returned intent.
431
+ #
432
+ #
433
+ # @yield [response, operation] Access the result along with the RPC operation
434
+ # @yieldparam response [Google::Cloud::Dialogflow::V2::Intent]
435
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
436
+ #
437
+ # @return [Google::Cloud::Dialogflow::V2::Intent]
438
+ #
439
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
440
+ #
441
+ def update_intent request, options = nil
442
+ raise ArgumentError, "request must be provided" if request.nil?
443
+
444
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Dialogflow::V2::UpdateIntentRequest
445
+
446
+ # Converts hash and nil to an options object
447
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
448
+
449
+ # Customize the options with defaults
450
+ metadata = @config.rpcs.update_intent.metadata.to_h
451
+
452
+ # Set x-goog-api-client and x-goog-user-project headers
453
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
454
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
455
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
456
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
457
+
458
+ header_params = {
459
+ "intent.name" => request.intent.name
460
+ }
461
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
462
+ metadata[:"x-goog-request-params"] ||= request_params_header
463
+
464
+ options.apply_defaults timeout: @config.rpcs.update_intent.timeout,
465
+ metadata: metadata,
466
+ retry_policy: @config.rpcs.update_intent.retry_policy
467
+ options.apply_defaults metadata: @config.metadata,
468
+ retry_policy: @config.retry_policy
469
+
470
+ @intents_stub.call_rpc :update_intent, request, options: options do |response, operation|
471
+ yield response, operation if block_given?
472
+ return response
473
+ end
474
+ rescue GRPC::BadStatus => e
475
+ raise Google::Cloud::Error.from_error(e)
476
+ end
477
+
478
+ ##
479
+ # Deletes the specified intent and its direct or indirect followup intents.
480
+ #
481
+ # @overload delete_intent(request, options = nil)
482
+ # @param request [Google::Cloud::Dialogflow::V2::DeleteIntentRequest | Hash]
483
+ # Deletes the specified intent and its direct or indirect followup intents.
484
+ # @param options [Gapic::CallOptions, Hash]
485
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
486
+ #
487
+ # @overload delete_intent(name: nil)
488
+ # @param name [String]
489
+ # Required. The name of the intent to delete. If this intent has direct or
490
+ # indirect followup intents, we also delete them.
491
+ # Format: `projects/<Project ID>/agent/intents/<Intent ID>`.
492
+ #
493
+ #
494
+ # @yield [response, operation] Access the result along with the RPC operation
495
+ # @yieldparam response [Google::Protobuf::Empty]
496
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
497
+ #
498
+ # @return [Google::Protobuf::Empty]
499
+ #
500
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
501
+ #
502
+ def delete_intent request, options = nil
503
+ raise ArgumentError, "request must be provided" if request.nil?
504
+
505
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Dialogflow::V2::DeleteIntentRequest
506
+
507
+ # Converts hash and nil to an options object
508
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
509
+
510
+ # Customize the options with defaults
511
+ metadata = @config.rpcs.delete_intent.metadata.to_h
512
+
513
+ # Set x-goog-api-client and x-goog-user-project headers
514
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
515
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
516
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
517
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
518
+
519
+ header_params = {
520
+ "name" => request.name
521
+ }
522
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
523
+ metadata[:"x-goog-request-params"] ||= request_params_header
524
+
525
+ options.apply_defaults timeout: @config.rpcs.delete_intent.timeout,
526
+ metadata: metadata,
527
+ retry_policy: @config.rpcs.delete_intent.retry_policy
528
+ options.apply_defaults metadata: @config.metadata,
529
+ retry_policy: @config.retry_policy
530
+
531
+ @intents_stub.call_rpc :delete_intent, request, options: options do |response, operation|
532
+ yield response, operation if block_given?
533
+ return response
534
+ end
535
+ rescue GRPC::BadStatus => e
536
+ raise Google::Cloud::Error.from_error(e)
537
+ end
538
+
539
+ ##
540
+ # Updates/Creates multiple intents in the specified agent.
541
+ #
542
+ # Operation <response: {Google::Cloud::Dialogflow::V2::BatchUpdateIntentsResponse BatchUpdateIntentsResponse}>
543
+ #
544
+ # @overload batch_update_intents(request, options = nil)
545
+ # @param request [Google::Cloud::Dialogflow::V2::BatchUpdateIntentsRequest | Hash]
546
+ # Updates/Creates multiple intents in the specified agent.
547
+ #
548
+ # Operation <response: {Google::Cloud::Dialogflow::V2::BatchUpdateIntentsResponse BatchUpdateIntentsResponse}>
549
+ # @param options [Gapic::CallOptions, Hash]
550
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
551
+ #
552
+ # @overload batch_update_intents(parent: nil, intent_batch_uri: nil, intent_batch_inline: nil, language_code: nil, update_mask: nil, intent_view: nil)
553
+ # @param parent [String]
554
+ # Required. The name of the agent to update or create intents in.
555
+ # Format: `projects/<Project ID>/agent`.
556
+ # @param intent_batch_uri [String]
557
+ # The URI to a Google Cloud Storage file containing intents to update or
558
+ # create. The file format can either be a serialized proto (of IntentBatch
559
+ # type) or JSON object. Note: The URI must start with "gs://".
560
+ # @param intent_batch_inline [Google::Cloud::Dialogflow::V2::IntentBatch | Hash]
561
+ # The collection of intents to update or create.
562
+ # @param language_code [String]
563
+ # Optional. The language of training phrases, parameters and rich messages
564
+ # defined in `intents`. If not specified, the agent's default language is
565
+ # used. [Many
566
+ # languages](https://cloud.google.com/dialogflow/docs/reference/language)
567
+ # are supported. Note: languages must be enabled in the agent before they can
568
+ # be used.
569
+ # @param update_mask [Google::Protobuf::FieldMask | Hash]
570
+ # Optional. The mask to control which fields get updated.
571
+ # @param intent_view [Google::Cloud::Dialogflow::V2::IntentView]
572
+ # Optional. The resource view to apply to the returned intent.
573
+ #
574
+ #
575
+ # @yield [response, operation] Access the result along with the RPC operation
576
+ # @yieldparam response [Gapic::Operation]
577
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
578
+ #
579
+ # @return [Gapic::Operation]
580
+ #
581
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
582
+ #
583
+ def batch_update_intents request, options = nil
584
+ raise ArgumentError, "request must be provided" if request.nil?
585
+
586
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Dialogflow::V2::BatchUpdateIntentsRequest
587
+
588
+ # Converts hash and nil to an options object
589
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
590
+
591
+ # Customize the options with defaults
592
+ metadata = @config.rpcs.batch_update_intents.metadata.to_h
593
+
594
+ # Set x-goog-api-client and x-goog-user-project headers
595
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
596
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
597
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
598
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
599
+
600
+ header_params = {
601
+ "parent" => request.parent
602
+ }
603
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
604
+ metadata[:"x-goog-request-params"] ||= request_params_header
605
+
606
+ options.apply_defaults timeout: @config.rpcs.batch_update_intents.timeout,
607
+ metadata: metadata,
608
+ retry_policy: @config.rpcs.batch_update_intents.retry_policy
609
+ options.apply_defaults metadata: @config.metadata,
610
+ retry_policy: @config.retry_policy
611
+
612
+ @intents_stub.call_rpc :batch_update_intents, request, options: options do |response, operation|
613
+ response = Gapic::Operation.new response, @operations_client, options: options
614
+ yield response, operation if block_given?
615
+ return response
616
+ end
617
+ rescue GRPC::BadStatus => e
618
+ raise Google::Cloud::Error.from_error(e)
619
+ end
620
+
621
+ ##
622
+ # Deletes intents in the specified agent.
623
+ #
624
+ # Operation <response: {Google::Protobuf::Empty google.protobuf.Empty}>
625
+ #
626
+ # @overload batch_delete_intents(request, options = nil)
627
+ # @param request [Google::Cloud::Dialogflow::V2::BatchDeleteIntentsRequest | Hash]
628
+ # Deletes intents in the specified agent.
629
+ #
630
+ # Operation <response: {Google::Protobuf::Empty google.protobuf.Empty}>
631
+ # @param options [Gapic::CallOptions, Hash]
632
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
633
+ #
634
+ # @overload batch_delete_intents(parent: nil, intents: nil)
635
+ # @param parent [String]
636
+ # Required. The name of the agent to delete all entities types for. Format:
637
+ # `projects/<Project ID>/agent`.
638
+ # @param intents [Array<Google::Cloud::Dialogflow::V2::Intent | Hash>]
639
+ # Required. The collection of intents to delete. Only intent `name` must be
640
+ # filled in.
641
+ #
642
+ #
643
+ # @yield [response, operation] Access the result along with the RPC operation
644
+ # @yieldparam response [Gapic::Operation]
645
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
646
+ #
647
+ # @return [Gapic::Operation]
648
+ #
649
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
650
+ #
651
+ def batch_delete_intents request, options = nil
652
+ raise ArgumentError, "request must be provided" if request.nil?
653
+
654
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Dialogflow::V2::BatchDeleteIntentsRequest
655
+
656
+ # Converts hash and nil to an options object
657
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
658
+
659
+ # Customize the options with defaults
660
+ metadata = @config.rpcs.batch_delete_intents.metadata.to_h
661
+
662
+ # Set x-goog-api-client and x-goog-user-project headers
663
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
664
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
665
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
666
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
667
+
668
+ header_params = {
669
+ "parent" => request.parent
670
+ }
671
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
672
+ metadata[:"x-goog-request-params"] ||= request_params_header
673
+
674
+ options.apply_defaults timeout: @config.rpcs.batch_delete_intents.timeout,
675
+ metadata: metadata,
676
+ retry_policy: @config.rpcs.batch_delete_intents.retry_policy
677
+ options.apply_defaults metadata: @config.metadata,
678
+ retry_policy: @config.retry_policy
679
+
680
+ @intents_stub.call_rpc :batch_delete_intents, request, options: options do |response, operation|
681
+ response = Gapic::Operation.new response, @operations_client, options: options
682
+ yield response, operation if block_given?
683
+ return response
684
+ end
685
+ rescue GRPC::BadStatus => e
686
+ raise Google::Cloud::Error.from_error(e)
687
+ end
688
+
689
+ ##
690
+ # Configuration class for the Intents API.
691
+ #
692
+ # This class represents the configuration for Intents,
693
+ # providing control over timeouts, retry behavior, logging, transport
694
+ # parameters, and other low-level controls. Certain parameters can also be
695
+ # applied individually to specific RPCs. See
696
+ # {Google::Cloud::Dialogflow::V2::Intents::Client::Configuration::Rpcs}
697
+ # for a list of RPCs that can be configured independently.
698
+ #
699
+ # Configuration can be applied globally to all clients, or to a single client
700
+ # on construction.
701
+ #
702
+ # # Examples
703
+ #
704
+ # To modify the global config, setting the timeout for list_intents
705
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
706
+ #
707
+ # Google::Cloud::Dialogflow::V2::Intents::Client.configure do |config|
708
+ # config.timeout = 10_000
709
+ # config.rpcs.list_intents.timeout = 20_000
710
+ # end
711
+ #
712
+ # To apply the above configuration only to a new client:
713
+ #
714
+ # client = Google::Cloud::Dialogflow::V2::Intents::Client.new do |config|
715
+ # config.timeout = 10_000
716
+ # config.rpcs.list_intents.timeout = 20_000
717
+ # end
718
+ #
719
+ # @!attribute [rw] endpoint
720
+ # The hostname or hostname:port of the service endpoint.
721
+ # Defaults to `"dialogflow.googleapis.com"`.
722
+ # @return [String]
723
+ # @!attribute [rw] credentials
724
+ # Credentials to send with calls. You may provide any of the following types:
725
+ # * (`String`) The path to a service account key file in JSON format
726
+ # * (`Hash`) A service account key as a Hash
727
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
728
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
729
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
730
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
731
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
732
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
733
+ # * (`nil`) indicating no credentials
734
+ # @return [Object]
735
+ # @!attribute [rw] scope
736
+ # The OAuth scopes
737
+ # @return [Array<String>]
738
+ # @!attribute [rw] lib_name
739
+ # The library name as recorded in instrumentation and logging
740
+ # @return [String]
741
+ # @!attribute [rw] lib_version
742
+ # The library version as recorded in instrumentation and logging
743
+ # @return [String]
744
+ # @!attribute [rw] channel_args
745
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
746
+ # `GRPC::Core::Channel` object is provided as the credential.
747
+ # @return [Hash]
748
+ # @!attribute [rw] interceptors
749
+ # An array of interceptors that are run before calls are executed.
750
+ # @return [Array<GRPC::ClientInterceptor>]
751
+ # @!attribute [rw] timeout
752
+ # The call timeout in milliseconds.
753
+ # @return [Numeric]
754
+ # @!attribute [rw] metadata
755
+ # Additional gRPC headers to be sent with the call.
756
+ # @return [Hash{Symbol=>String}]
757
+ # @!attribute [rw] retry_policy
758
+ # The retry policy. The value is a hash with the following keys:
759
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
760
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
761
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
762
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
763
+ # trigger a retry.
764
+ # @return [Hash]
765
+ #
766
+ class Configuration
767
+ extend Gapic::Config
768
+
769
+ config_attr :endpoint, "dialogflow.googleapis.com", String
770
+ config_attr :credentials, nil do |value|
771
+ allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
772
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
773
+ allowed.any? { |klass| klass === value }
774
+ end
775
+ config_attr :scope, nil, String, Array, nil
776
+ config_attr :lib_name, nil, String, nil
777
+ config_attr :lib_version, nil, String, nil
778
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, Hash, nil)
779
+ config_attr :interceptors, nil, Array, nil
780
+ config_attr :timeout, nil, Numeric, nil
781
+ config_attr :metadata, nil, Hash, nil
782
+ config_attr :retry_policy, nil, Hash, Proc, nil
783
+
784
+ # @private
785
+ def initialize parent_config = nil
786
+ @parent_config = parent_config unless parent_config.nil?
787
+
788
+ yield self if block_given?
789
+ end
790
+
791
+ ##
792
+ # Configurations for individual RPCs
793
+ # @return [Rpcs]
794
+ #
795
+ def rpcs
796
+ @rpcs ||= begin
797
+ parent_rpcs = nil
798
+ parent_rpcs = @parent_config.rpcs if @parent_config&.respond_to? :rpcs
799
+ Rpcs.new parent_rpcs
800
+ end
801
+ end
802
+
803
+ ##
804
+ # Configuration RPC class for the Intents API.
805
+ #
806
+ # Includes fields providing the configuration for each RPC in this service.
807
+ # Each configuration object is of type `Gapic::Config::Method` and includes
808
+ # the following configuration fields:
809
+ #
810
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
811
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
812
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
813
+ # include the following keys:
814
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
815
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
816
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
817
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
818
+ # trigger a retry.
819
+ #
820
+ class Rpcs
821
+ ##
822
+ # RPC-specific configuration for `list_intents`
823
+ # @return [Gapic::Config::Method]
824
+ #
825
+ attr_reader :list_intents
826
+ ##
827
+ # RPC-specific configuration for `get_intent`
828
+ # @return [Gapic::Config::Method]
829
+ #
830
+ attr_reader :get_intent
831
+ ##
832
+ # RPC-specific configuration for `create_intent`
833
+ # @return [Gapic::Config::Method]
834
+ #
835
+ attr_reader :create_intent
836
+ ##
837
+ # RPC-specific configuration for `update_intent`
838
+ # @return [Gapic::Config::Method]
839
+ #
840
+ attr_reader :update_intent
841
+ ##
842
+ # RPC-specific configuration for `delete_intent`
843
+ # @return [Gapic::Config::Method]
844
+ #
845
+ attr_reader :delete_intent
846
+ ##
847
+ # RPC-specific configuration for `batch_update_intents`
848
+ # @return [Gapic::Config::Method]
849
+ #
850
+ attr_reader :batch_update_intents
851
+ ##
852
+ # RPC-specific configuration for `batch_delete_intents`
853
+ # @return [Gapic::Config::Method]
854
+ #
855
+ attr_reader :batch_delete_intents
856
+
857
+ # @private
858
+ def initialize parent_rpcs = nil
859
+ list_intents_config = parent_rpcs&.list_intents if parent_rpcs&.respond_to? :list_intents
860
+ @list_intents = Gapic::Config::Method.new list_intents_config
861
+ get_intent_config = parent_rpcs&.get_intent if parent_rpcs&.respond_to? :get_intent
862
+ @get_intent = Gapic::Config::Method.new get_intent_config
863
+ create_intent_config = parent_rpcs&.create_intent if parent_rpcs&.respond_to? :create_intent
864
+ @create_intent = Gapic::Config::Method.new create_intent_config
865
+ update_intent_config = parent_rpcs&.update_intent if parent_rpcs&.respond_to? :update_intent
866
+ @update_intent = Gapic::Config::Method.new update_intent_config
867
+ delete_intent_config = parent_rpcs&.delete_intent if parent_rpcs&.respond_to? :delete_intent
868
+ @delete_intent = Gapic::Config::Method.new delete_intent_config
869
+ batch_update_intents_config = parent_rpcs&.batch_update_intents if parent_rpcs&.respond_to? :batch_update_intents
870
+ @batch_update_intents = Gapic::Config::Method.new batch_update_intents_config
871
+ batch_delete_intents_config = parent_rpcs&.batch_delete_intents if parent_rpcs&.respond_to? :batch_delete_intents
872
+ @batch_delete_intents = Gapic::Config::Method.new batch_delete_intents_config
873
+
874
+ yield self if block_given?
875
+ end
876
+ end
877
+ end
878
+ end
879
+ end
880
+ end
881
+ end
882
+ end
883
+ end
884
+
885
+ # rubocop:disable Lint/HandleExceptions
886
+
887
+ # Once client is loaded, load helpers.rb if it exists.
888
+ begin
889
+ require "google/cloud/dialogflow/v2/intents/helpers"
890
+ rescue LoadError
891
+ end
892
+
893
+ # rubocop:enable Lint/HandleExceptions