google-cloud-dialogflow-v2 0.22.0 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/google/cloud/dialogflow/v2/agents/rest/client.rb +1078 -0
  4. data/lib/google/cloud/dialogflow/v2/agents/rest/operations.rb +813 -0
  5. data/lib/google/cloud/dialogflow/v2/agents/rest/service_stub.rb +652 -0
  6. data/lib/google/cloud/dialogflow/v2/agents/rest.rb +54 -0
  7. data/lib/google/cloud/dialogflow/v2/agents.rb +6 -0
  8. data/lib/google/cloud/dialogflow/v2/answer_records/rest/client.rb +463 -0
  9. data/lib/google/cloud/dialogflow/v2/answer_records/rest/service_stub.rb +182 -0
  10. data/lib/google/cloud/dialogflow/v2/answer_records/rest.rb +54 -0
  11. data/lib/google/cloud/dialogflow/v2/answer_records.rb +6 -0
  12. data/lib/google/cloud/dialogflow/v2/bindings_override.rb +102 -0
  13. data/lib/google/cloud/dialogflow/v2/contexts/rest/client.rb +753 -0
  14. data/lib/google/cloud/dialogflow/v2/contexts/rest/service_stub.rb +536 -0
  15. data/lib/google/cloud/dialogflow/v2/contexts/rest.rb +53 -0
  16. data/lib/google/cloud/dialogflow/v2/contexts.rb +6 -0
  17. data/lib/google/cloud/dialogflow/v2/conversation_datasets/rest/client.rb +714 -0
  18. data/lib/google/cloud/dialogflow/v2/conversation_datasets/rest/operations.rb +813 -0
  19. data/lib/google/cloud/dialogflow/v2/conversation_datasets/rest/service_stub.rb +367 -0
  20. data/lib/google/cloud/dialogflow/v2/conversation_datasets/rest.rb +57 -0
  21. data/lib/google/cloud/dialogflow/v2/conversation_datasets.rb +6 -0
  22. data/lib/google/cloud/dialogflow/v2/conversation_models/rest/client.rb +1010 -0
  23. data/lib/google/cloud/dialogflow/v2/conversation_models/rest/operations.rb +813 -0
  24. data/lib/google/cloud/dialogflow/v2/conversation_models/rest/service_stub.rb +642 -0
  25. data/lib/google/cloud/dialogflow/v2/conversation_models/rest.rb +54 -0
  26. data/lib/google/cloud/dialogflow/v2/conversation_models.rb +6 -0
  27. data/lib/google/cloud/dialogflow/v2/conversation_profiles/rest/client.rb +868 -0
  28. data/lib/google/cloud/dialogflow/v2/conversation_profiles/rest/operations.rb +813 -0
  29. data/lib/google/cloud/dialogflow/v2/conversation_profiles/rest/service_stub.rb +518 -0
  30. data/lib/google/cloud/dialogflow/v2/conversation_profiles/rest.rb +55 -0
  31. data/lib/google/cloud/dialogflow/v2/conversation_profiles.rb +6 -0
  32. data/lib/google/cloud/dialogflow/v2/conversations/rest/client.rb +819 -0
  33. data/lib/google/cloud/dialogflow/v2/conversations/rest/service_stub.rb +450 -0
  34. data/lib/google/cloud/dialogflow/v2/conversations/rest.rb +54 -0
  35. data/lib/google/cloud/dialogflow/v2/conversations.rb +6 -0
  36. data/lib/google/cloud/dialogflow/v2/documents/rest/client.rb +1013 -0
  37. data/lib/google/cloud/dialogflow/v2/documents/rest/operations.rb +813 -0
  38. data/lib/google/cloud/dialogflow/v2/documents/rest/service_stub.rb +631 -0
  39. data/lib/google/cloud/dialogflow/v2/documents/rest.rb +55 -0
  40. data/lib/google/cloud/dialogflow/v2/documents.rb +6 -0
  41. data/lib/google/cloud/dialogflow/v2/entity_types/rest/client.rb +1178 -0
  42. data/lib/google/cloud/dialogflow/v2/entity_types/rest/operations.rb +813 -0
  43. data/lib/google/cloud/dialogflow/v2/entity_types/rest/service_stub.rb +722 -0
  44. data/lib/google/cloud/dialogflow/v2/entity_types/rest.rb +54 -0
  45. data/lib/google/cloud/dialogflow/v2/entity_types.rb +6 -0
  46. data/lib/google/cloud/dialogflow/v2/environments/rest/client.rb +779 -0
  47. data/lib/google/cloud/dialogflow/v2/environments/rest/service_stub.rb +448 -0
  48. data/lib/google/cloud/dialogflow/v2/environments/rest.rb +53 -0
  49. data/lib/google/cloud/dialogflow/v2/environments.rb +6 -0
  50. data/lib/google/cloud/dialogflow/v2/fulfillments/rest/client.rb +444 -0
  51. data/lib/google/cloud/dialogflow/v2/fulfillments/rest/service_stub.rb +182 -0
  52. data/lib/google/cloud/dialogflow/v2/fulfillments/rest.rb +53 -0
  53. data/lib/google/cloud/dialogflow/v2/fulfillments.rb +6 -0
  54. data/lib/google/cloud/dialogflow/v2/intents/rest/client.rb +914 -0
  55. data/lib/google/cloud/dialogflow/v2/intents/rest/operations.rb +813 -0
  56. data/lib/google/cloud/dialogflow/v2/intents/rest/service_stub.rb +532 -0
  57. data/lib/google/cloud/dialogflow/v2/intents/rest.rb +54 -0
  58. data/lib/google/cloud/dialogflow/v2/intents.rb +6 -0
  59. data/lib/google/cloud/dialogflow/v2/knowledge_bases/rest/client.rb +696 -0
  60. data/lib/google/cloud/dialogflow/v2/knowledge_bases/rest/service_stub.rb +419 -0
  61. data/lib/google/cloud/dialogflow/v2/knowledge_bases/rest.rb +54 -0
  62. data/lib/google/cloud/dialogflow/v2/knowledge_bases.rb +6 -0
  63. data/lib/google/cloud/dialogflow/v2/participants/rest/client.rb +955 -0
  64. data/lib/google/cloud/dialogflow/v2/participants/rest/service_stub.rb +588 -0
  65. data/lib/google/cloud/dialogflow/v2/participants/rest.rb +53 -0
  66. data/lib/google/cloud/dialogflow/v2/participants.rb +6 -0
  67. data/lib/google/cloud/dialogflow/v2/rest.rb +54 -0
  68. data/lib/google/cloud/dialogflow/v2/session_entity_types/rest/client.rb +703 -0
  69. data/lib/google/cloud/dialogflow/v2/session_entity_types/rest/service_stub.rb +456 -0
  70. data/lib/google/cloud/dialogflow/v2/session_entity_types/rest.rb +54 -0
  71. data/lib/google/cloud/dialogflow/v2/session_entity_types.rb +6 -0
  72. data/lib/google/cloud/dialogflow/v2/sessions/rest/client.rb +437 -0
  73. data/lib/google/cloud/dialogflow/v2/sessions/rest/service_stub.rb +132 -0
  74. data/lib/google/cloud/dialogflow/v2/sessions/rest.rb +56 -0
  75. data/lib/google/cloud/dialogflow/v2/sessions.rb +6 -0
  76. data/lib/google/cloud/dialogflow/v2/version.rb +1 -1
  77. data/lib/google/cloud/dialogflow/v2/versions/rest/client.rb +686 -0
  78. data/lib/google/cloud/dialogflow/v2/versions/rest/service_stub.rb +382 -0
  79. data/lib/google/cloud/dialogflow/v2/versions/rest.rb +53 -0
  80. data/lib/google/cloud/dialogflow/v2/versions.rb +6 -0
  81. data/lib/google/cloud/dialogflow/v2.rb +5 -0
  82. metadata +66 -5
@@ -0,0 +1,753 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 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/errors"
20
+ require "google/cloud/dialogflow/v2/context_pb"
21
+ require "google/cloud/dialogflow/v2/contexts/rest/service_stub"
22
+ require "google/cloud/location/rest"
23
+
24
+ module Google
25
+ module Cloud
26
+ module Dialogflow
27
+ module V2
28
+ module Contexts
29
+ module Rest
30
+ ##
31
+ # REST client for the Contexts service.
32
+ #
33
+ # Service for managing {::Google::Cloud::Dialogflow::V2::Context Contexts}.
34
+ #
35
+ class Client
36
+ include Paths
37
+
38
+ # @private
39
+ attr_reader :contexts_stub
40
+
41
+ ##
42
+ # Configure the Contexts Client class.
43
+ #
44
+ # See {::Google::Cloud::Dialogflow::V2::Contexts::Rest::Client::Configuration}
45
+ # for a description of the configuration fields.
46
+ #
47
+ # @example
48
+ #
49
+ # # Modify the configuration for all Contexts clients
50
+ # ::Google::Cloud::Dialogflow::V2::Contexts::Rest::Client.configure do |config|
51
+ # config.timeout = 10.0
52
+ # end
53
+ #
54
+ # @yield [config] Configure the Client client.
55
+ # @yieldparam config [Client::Configuration]
56
+ #
57
+ # @return [Client::Configuration]
58
+ #
59
+ def self.configure
60
+ @configure ||= begin
61
+ namespace = ["Google", "Cloud", "Dialogflow", "V2"]
62
+ parent_config = while namespace.any?
63
+ parent_name = namespace.join "::"
64
+ parent_const = const_get parent_name
65
+ break parent_const.configure if parent_const.respond_to? :configure
66
+ namespace.pop
67
+ end
68
+ default_config = Client::Configuration.new parent_config
69
+
70
+ default_config.timeout = 60.0
71
+ default_config.retry_policy = {
72
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14]
73
+ }
74
+
75
+ default_config
76
+ end
77
+ yield @configure if block_given?
78
+ @configure
79
+ end
80
+
81
+ ##
82
+ # Configure the Contexts Client instance.
83
+ #
84
+ # The configuration is set to the derived mode, meaning that values can be changed,
85
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
86
+ # should be made on {Client.configure}.
87
+ #
88
+ # See {::Google::Cloud::Dialogflow::V2::Contexts::Rest::Client::Configuration}
89
+ # for a description of the configuration fields.
90
+ #
91
+ # @yield [config] Configure the Client client.
92
+ # @yieldparam config [Client::Configuration]
93
+ #
94
+ # @return [Client::Configuration]
95
+ #
96
+ def configure
97
+ yield @config if block_given?
98
+ @config
99
+ end
100
+
101
+ ##
102
+ # Create a new Contexts REST client object.
103
+ #
104
+ # @example
105
+ #
106
+ # # Create a client using the default configuration
107
+ # client = ::Google::Cloud::Dialogflow::V2::Contexts::Rest::Client.new
108
+ #
109
+ # # Create a client using a custom configuration
110
+ # client = ::Google::Cloud::Dialogflow::V2::Contexts::Rest::Client.new do |config|
111
+ # config.timeout = 10.0
112
+ # end
113
+ #
114
+ # @yield [config] Configure the Contexts client.
115
+ # @yieldparam config [Client::Configuration]
116
+ #
117
+ def initialize
118
+ # Create the configuration object
119
+ @config = Configuration.new Client.configure
120
+
121
+ # Yield the configuration if needed
122
+ yield @config if block_given?
123
+
124
+ # Create credentials
125
+ credentials = @config.credentials
126
+ # Use self-signed JWT if the endpoint is unchanged from default,
127
+ # but only if the default endpoint does not have a region prefix.
128
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
129
+ !@config.endpoint.split(".").first.include?("-")
130
+ credentials ||= Credentials.default scope: @config.scope,
131
+ enable_self_signed_jwt: enable_self_signed_jwt
132
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
133
+ credentials = Credentials.new credentials, scope: @config.scope
134
+ end
135
+
136
+ @quota_project_id = @config.quota_project
137
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
138
+
139
+ @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
140
+ config.credentials = credentials
141
+ config.quota_project = @quota_project_id
142
+ config.endpoint = @config.endpoint
143
+ config.bindings_override = @config.bindings_override
144
+ end
145
+
146
+ @contexts_stub = ::Google::Cloud::Dialogflow::V2::Contexts::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
147
+ end
148
+
149
+ ##
150
+ # Get the associated client for mix-in of the Locations.
151
+ #
152
+ # @return [Google::Cloud::Location::Locations::Rest::Client]
153
+ #
154
+ attr_reader :location_client
155
+
156
+ # Service calls
157
+
158
+ ##
159
+ # Returns the list of all contexts in the specified session.
160
+ #
161
+ # @overload list_contexts(request, options = nil)
162
+ # Pass arguments to `list_contexts` via a request object, either of type
163
+ # {::Google::Cloud::Dialogflow::V2::ListContextsRequest} or an equivalent Hash.
164
+ #
165
+ # @param request [::Google::Cloud::Dialogflow::V2::ListContextsRequest, ::Hash]
166
+ # A request object representing the call parameters. Required. To specify no
167
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
168
+ # @param options [::Gapic::CallOptions, ::Hash]
169
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
170
+ #
171
+ # @overload list_contexts(parent: nil, page_size: nil, page_token: nil)
172
+ # Pass arguments to `list_contexts` via keyword arguments. Note that at
173
+ # least one keyword argument is required. To specify no parameters, or to keep all
174
+ # the default parameter values, pass an empty Hash as a request object (see above).
175
+ #
176
+ # @param parent [::String]
177
+ # Required. The session to list all contexts from.
178
+ # Format: `projects/<Project ID>/agent/sessions/<Session ID>` or
179
+ # `projects/<Project ID>/agent/environments/<Environment ID>/users/<User
180
+ # ID>/sessions/<Session ID>`.
181
+ # If `Environment ID` is not specified, we assume default 'draft'
182
+ # environment. If `User ID` is not specified, we assume default '-' user.
183
+ # @param page_size [::Integer]
184
+ # Optional. The maximum number of items to return in a single page. By
185
+ # default 100 and at most 1000.
186
+ # @param page_token [::String]
187
+ # Optional. The next_page_token value returned from a previous list request.
188
+ # @yield [result, operation] Access the result along with the TransportOperation object
189
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Context>]
190
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
191
+ #
192
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Context>]
193
+ #
194
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
195
+ def list_contexts request, options = nil
196
+ raise ::ArgumentError, "request must be provided" if request.nil?
197
+
198
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::ListContextsRequest
199
+
200
+ # Converts hash and nil to an options object
201
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
202
+
203
+ # Customize the options with defaults
204
+ call_metadata = @config.rpcs.list_contexts.metadata.to_h
205
+
206
+ # Set x-goog-api-client and x-goog-user-project headers
207
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
208
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
209
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION,
210
+ transports_version_send: [:rest]
211
+
212
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
213
+
214
+ options.apply_defaults timeout: @config.rpcs.list_contexts.timeout,
215
+ metadata: call_metadata,
216
+ retry_policy: @config.rpcs.list_contexts.retry_policy
217
+
218
+ options.apply_defaults timeout: @config.timeout,
219
+ metadata: @config.metadata,
220
+ retry_policy: @config.retry_policy
221
+
222
+ @contexts_stub.list_contexts request, options do |result, operation|
223
+ result = ::Gapic::Rest::PagedEnumerable.new @contexts_stub, :list_contexts, "contexts", request, result, options
224
+ yield result, operation if block_given?
225
+ return result
226
+ end
227
+ rescue ::Gapic::Rest::Error => e
228
+ raise ::Google::Cloud::Error.from_error(e)
229
+ end
230
+
231
+ ##
232
+ # Retrieves the specified context.
233
+ #
234
+ # @overload get_context(request, options = nil)
235
+ # Pass arguments to `get_context` via a request object, either of type
236
+ # {::Google::Cloud::Dialogflow::V2::GetContextRequest} or an equivalent Hash.
237
+ #
238
+ # @param request [::Google::Cloud::Dialogflow::V2::GetContextRequest, ::Hash]
239
+ # A request object representing the call parameters. Required. To specify no
240
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
241
+ # @param options [::Gapic::CallOptions, ::Hash]
242
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
243
+ #
244
+ # @overload get_context(name: nil)
245
+ # Pass arguments to `get_context` via keyword arguments. Note that at
246
+ # least one keyword argument is required. To specify no parameters, or to keep all
247
+ # the default parameter values, pass an empty Hash as a request object (see above).
248
+ #
249
+ # @param name [::String]
250
+ # Required. The name of the context. Format:
251
+ # `projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>`
252
+ # or `projects/<Project ID>/agent/environments/<Environment ID>/users/<User
253
+ # ID>/sessions/<Session ID>/contexts/<Context ID>`.
254
+ # If `Environment ID` is not specified, we assume default 'draft'
255
+ # environment. If `User ID` is not specified, we assume default '-' user.
256
+ # @yield [result, operation] Access the result along with the TransportOperation object
257
+ # @yieldparam result [::Google::Cloud::Dialogflow::V2::Context]
258
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
259
+ #
260
+ # @return [::Google::Cloud::Dialogflow::V2::Context]
261
+ #
262
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
263
+ def get_context request, options = nil
264
+ raise ::ArgumentError, "request must be provided" if request.nil?
265
+
266
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::GetContextRequest
267
+
268
+ # Converts hash and nil to an options object
269
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
270
+
271
+ # Customize the options with defaults
272
+ call_metadata = @config.rpcs.get_context.metadata.to_h
273
+
274
+ # Set x-goog-api-client and x-goog-user-project headers
275
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
276
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
277
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION,
278
+ transports_version_send: [:rest]
279
+
280
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
281
+
282
+ options.apply_defaults timeout: @config.rpcs.get_context.timeout,
283
+ metadata: call_metadata,
284
+ retry_policy: @config.rpcs.get_context.retry_policy
285
+
286
+ options.apply_defaults timeout: @config.timeout,
287
+ metadata: @config.metadata,
288
+ retry_policy: @config.retry_policy
289
+
290
+ @contexts_stub.get_context request, options do |result, operation|
291
+ yield result, operation if block_given?
292
+ return result
293
+ end
294
+ rescue ::Gapic::Rest::Error => e
295
+ raise ::Google::Cloud::Error.from_error(e)
296
+ end
297
+
298
+ ##
299
+ # Creates a context.
300
+ #
301
+ # If the specified context already exists, overrides the context.
302
+ #
303
+ # @overload create_context(request, options = nil)
304
+ # Pass arguments to `create_context` via a request object, either of type
305
+ # {::Google::Cloud::Dialogflow::V2::CreateContextRequest} or an equivalent Hash.
306
+ #
307
+ # @param request [::Google::Cloud::Dialogflow::V2::CreateContextRequest, ::Hash]
308
+ # A request object representing the call parameters. Required. To specify no
309
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
310
+ # @param options [::Gapic::CallOptions, ::Hash]
311
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
312
+ #
313
+ # @overload create_context(parent: nil, context: nil)
314
+ # Pass arguments to `create_context` via keyword arguments. Note that at
315
+ # least one keyword argument is required. To specify no parameters, or to keep all
316
+ # the default parameter values, pass an empty Hash as a request object (see above).
317
+ #
318
+ # @param parent [::String]
319
+ # Required. The session to create a context for.
320
+ # Format: `projects/<Project ID>/agent/sessions/<Session ID>` or
321
+ # `projects/<Project ID>/agent/environments/<Environment ID>/users/<User
322
+ # ID>/sessions/<Session ID>`.
323
+ # If `Environment ID` is not specified, we assume default 'draft'
324
+ # environment. If `User ID` is not specified, we assume default '-' user.
325
+ # @param context [::Google::Cloud::Dialogflow::V2::Context, ::Hash]
326
+ # Required. The context to create.
327
+ # @yield [result, operation] Access the result along with the TransportOperation object
328
+ # @yieldparam result [::Google::Cloud::Dialogflow::V2::Context]
329
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
330
+ #
331
+ # @return [::Google::Cloud::Dialogflow::V2::Context]
332
+ #
333
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
334
+ def create_context request, options = nil
335
+ raise ::ArgumentError, "request must be provided" if request.nil?
336
+
337
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::CreateContextRequest
338
+
339
+ # Converts hash and nil to an options object
340
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
341
+
342
+ # Customize the options with defaults
343
+ call_metadata = @config.rpcs.create_context.metadata.to_h
344
+
345
+ # Set x-goog-api-client and x-goog-user-project headers
346
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
347
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
348
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION,
349
+ transports_version_send: [:rest]
350
+
351
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
352
+
353
+ options.apply_defaults timeout: @config.rpcs.create_context.timeout,
354
+ metadata: call_metadata,
355
+ retry_policy: @config.rpcs.create_context.retry_policy
356
+
357
+ options.apply_defaults timeout: @config.timeout,
358
+ metadata: @config.metadata,
359
+ retry_policy: @config.retry_policy
360
+
361
+ @contexts_stub.create_context request, options do |result, operation|
362
+ yield result, operation if block_given?
363
+ return result
364
+ end
365
+ rescue ::Gapic::Rest::Error => e
366
+ raise ::Google::Cloud::Error.from_error(e)
367
+ end
368
+
369
+ ##
370
+ # Updates the specified context.
371
+ #
372
+ # @overload update_context(request, options = nil)
373
+ # Pass arguments to `update_context` via a request object, either of type
374
+ # {::Google::Cloud::Dialogflow::V2::UpdateContextRequest} or an equivalent Hash.
375
+ #
376
+ # @param request [::Google::Cloud::Dialogflow::V2::UpdateContextRequest, ::Hash]
377
+ # A request object representing the call parameters. Required. To specify no
378
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
379
+ # @param options [::Gapic::CallOptions, ::Hash]
380
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
381
+ #
382
+ # @overload update_context(context: nil, update_mask: nil)
383
+ # Pass arguments to `update_context` via keyword arguments. Note that at
384
+ # least one keyword argument is required. To specify no parameters, or to keep all
385
+ # the default parameter values, pass an empty Hash as a request object (see above).
386
+ #
387
+ # @param context [::Google::Cloud::Dialogflow::V2::Context, ::Hash]
388
+ # Required. The context to update.
389
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
390
+ # Optional. The mask to control which fields get updated.
391
+ # @yield [result, operation] Access the result along with the TransportOperation object
392
+ # @yieldparam result [::Google::Cloud::Dialogflow::V2::Context]
393
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
394
+ #
395
+ # @return [::Google::Cloud::Dialogflow::V2::Context]
396
+ #
397
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
398
+ def update_context request, options = nil
399
+ raise ::ArgumentError, "request must be provided" if request.nil?
400
+
401
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::UpdateContextRequest
402
+
403
+ # Converts hash and nil to an options object
404
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
405
+
406
+ # Customize the options with defaults
407
+ call_metadata = @config.rpcs.update_context.metadata.to_h
408
+
409
+ # Set x-goog-api-client and x-goog-user-project headers
410
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
411
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
412
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION,
413
+ transports_version_send: [:rest]
414
+
415
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
416
+
417
+ options.apply_defaults timeout: @config.rpcs.update_context.timeout,
418
+ metadata: call_metadata,
419
+ retry_policy: @config.rpcs.update_context.retry_policy
420
+
421
+ options.apply_defaults timeout: @config.timeout,
422
+ metadata: @config.metadata,
423
+ retry_policy: @config.retry_policy
424
+
425
+ @contexts_stub.update_context request, options do |result, operation|
426
+ yield result, operation if block_given?
427
+ return result
428
+ end
429
+ rescue ::Gapic::Rest::Error => e
430
+ raise ::Google::Cloud::Error.from_error(e)
431
+ end
432
+
433
+ ##
434
+ # Deletes the specified context.
435
+ #
436
+ # @overload delete_context(request, options = nil)
437
+ # Pass arguments to `delete_context` via a request object, either of type
438
+ # {::Google::Cloud::Dialogflow::V2::DeleteContextRequest} or an equivalent Hash.
439
+ #
440
+ # @param request [::Google::Cloud::Dialogflow::V2::DeleteContextRequest, ::Hash]
441
+ # A request object representing the call parameters. Required. To specify no
442
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
443
+ # @param options [::Gapic::CallOptions, ::Hash]
444
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
445
+ #
446
+ # @overload delete_context(name: nil)
447
+ # Pass arguments to `delete_context` via keyword arguments. Note that at
448
+ # least one keyword argument is required. To specify no parameters, or to keep all
449
+ # the default parameter values, pass an empty Hash as a request object (see above).
450
+ #
451
+ # @param name [::String]
452
+ # Required. The name of the context to delete. Format:
453
+ # `projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>`
454
+ # or `projects/<Project ID>/agent/environments/<Environment ID>/users/<User
455
+ # ID>/sessions/<Session ID>/contexts/<Context ID>`.
456
+ # If `Environment ID` is not specified, we assume default 'draft'
457
+ # environment. If `User ID` is not specified, we assume default '-' user.
458
+ # @yield [result, operation] Access the result along with the TransportOperation object
459
+ # @yieldparam result [::Google::Protobuf::Empty]
460
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
461
+ #
462
+ # @return [::Google::Protobuf::Empty]
463
+ #
464
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
465
+ def delete_context request, options = nil
466
+ raise ::ArgumentError, "request must be provided" if request.nil?
467
+
468
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::DeleteContextRequest
469
+
470
+ # Converts hash and nil to an options object
471
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
472
+
473
+ # Customize the options with defaults
474
+ call_metadata = @config.rpcs.delete_context.metadata.to_h
475
+
476
+ # Set x-goog-api-client and x-goog-user-project headers
477
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
478
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
479
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION,
480
+ transports_version_send: [:rest]
481
+
482
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
483
+
484
+ options.apply_defaults timeout: @config.rpcs.delete_context.timeout,
485
+ metadata: call_metadata,
486
+ retry_policy: @config.rpcs.delete_context.retry_policy
487
+
488
+ options.apply_defaults timeout: @config.timeout,
489
+ metadata: @config.metadata,
490
+ retry_policy: @config.retry_policy
491
+
492
+ @contexts_stub.delete_context request, options do |result, operation|
493
+ yield result, operation if block_given?
494
+ return result
495
+ end
496
+ rescue ::Gapic::Rest::Error => e
497
+ raise ::Google::Cloud::Error.from_error(e)
498
+ end
499
+
500
+ ##
501
+ # Deletes all active contexts in the specified session.
502
+ #
503
+ # @overload delete_all_contexts(request, options = nil)
504
+ # Pass arguments to `delete_all_contexts` via a request object, either of type
505
+ # {::Google::Cloud::Dialogflow::V2::DeleteAllContextsRequest} or an equivalent Hash.
506
+ #
507
+ # @param request [::Google::Cloud::Dialogflow::V2::DeleteAllContextsRequest, ::Hash]
508
+ # A request object representing the call parameters. Required. To specify no
509
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
510
+ # @param options [::Gapic::CallOptions, ::Hash]
511
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
512
+ #
513
+ # @overload delete_all_contexts(parent: nil)
514
+ # Pass arguments to `delete_all_contexts` via keyword arguments. Note that at
515
+ # least one keyword argument is required. To specify no parameters, or to keep all
516
+ # the default parameter values, pass an empty Hash as a request object (see above).
517
+ #
518
+ # @param parent [::String]
519
+ # Required. The name of the session to delete all contexts from. Format:
520
+ # `projects/<Project ID>/agent/sessions/<Session ID>` or `projects/<Project
521
+ # ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session
522
+ # ID>`.
523
+ # If `Environment ID` is not specified we assume default 'draft' environment.
524
+ # If `User ID` is not specified, we assume default '-' user.
525
+ # @yield [result, operation] Access the result along with the TransportOperation object
526
+ # @yieldparam result [::Google::Protobuf::Empty]
527
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
528
+ #
529
+ # @return [::Google::Protobuf::Empty]
530
+ #
531
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
532
+ def delete_all_contexts request, options = nil
533
+ raise ::ArgumentError, "request must be provided" if request.nil?
534
+
535
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::DeleteAllContextsRequest
536
+
537
+ # Converts hash and nil to an options object
538
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
539
+
540
+ # Customize the options with defaults
541
+ call_metadata = @config.rpcs.delete_all_contexts.metadata.to_h
542
+
543
+ # Set x-goog-api-client and x-goog-user-project headers
544
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
545
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
546
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION,
547
+ transports_version_send: [:rest]
548
+
549
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
550
+
551
+ options.apply_defaults timeout: @config.rpcs.delete_all_contexts.timeout,
552
+ metadata: call_metadata,
553
+ retry_policy: @config.rpcs.delete_all_contexts.retry_policy
554
+
555
+ options.apply_defaults timeout: @config.timeout,
556
+ metadata: @config.metadata,
557
+ retry_policy: @config.retry_policy
558
+
559
+ @contexts_stub.delete_all_contexts request, options do |result, operation|
560
+ yield result, operation if block_given?
561
+ return result
562
+ end
563
+ rescue ::Gapic::Rest::Error => e
564
+ raise ::Google::Cloud::Error.from_error(e)
565
+ end
566
+
567
+ ##
568
+ # Configuration class for the Contexts REST API.
569
+ #
570
+ # This class represents the configuration for Contexts REST,
571
+ # providing control over timeouts, retry behavior, logging, transport
572
+ # parameters, and other low-level controls. Certain parameters can also be
573
+ # applied individually to specific RPCs. See
574
+ # {::Google::Cloud::Dialogflow::V2::Contexts::Rest::Client::Configuration::Rpcs}
575
+ # for a list of RPCs that can be configured independently.
576
+ #
577
+ # Configuration can be applied globally to all clients, or to a single client
578
+ # on construction.
579
+ #
580
+ # @example
581
+ #
582
+ # # Modify the global config, setting the timeout for
583
+ # # list_contexts to 20 seconds,
584
+ # # and all remaining timeouts to 10 seconds.
585
+ # ::Google::Cloud::Dialogflow::V2::Contexts::Rest::Client.configure do |config|
586
+ # config.timeout = 10.0
587
+ # config.rpcs.list_contexts.timeout = 20.0
588
+ # end
589
+ #
590
+ # # Apply the above configuration only to a new client.
591
+ # client = ::Google::Cloud::Dialogflow::V2::Contexts::Rest::Client.new do |config|
592
+ # config.timeout = 10.0
593
+ # config.rpcs.list_contexts.timeout = 20.0
594
+ # end
595
+ #
596
+ # @!attribute [rw] endpoint
597
+ # The hostname or hostname:port of the service endpoint.
598
+ # Defaults to `"dialogflow.googleapis.com"`.
599
+ # @return [::String]
600
+ # @!attribute [rw] credentials
601
+ # Credentials to send with calls. You may provide any of the following types:
602
+ # * (`String`) The path to a service account key file in JSON format
603
+ # * (`Hash`) A service account key as a Hash
604
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
605
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
606
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
607
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
608
+ # * (`nil`) indicating no credentials
609
+ # @return [::Object]
610
+ # @!attribute [rw] scope
611
+ # The OAuth scopes
612
+ # @return [::Array<::String>]
613
+ # @!attribute [rw] lib_name
614
+ # The library name as recorded in instrumentation and logging
615
+ # @return [::String]
616
+ # @!attribute [rw] lib_version
617
+ # The library version as recorded in instrumentation and logging
618
+ # @return [::String]
619
+ # @!attribute [rw] timeout
620
+ # The call timeout in seconds.
621
+ # @return [::Numeric]
622
+ # @!attribute [rw] metadata
623
+ # Additional headers to be sent with the call.
624
+ # @return [::Hash{::Symbol=>::String}]
625
+ # @!attribute [rw] retry_policy
626
+ # The retry policy. The value is a hash with the following keys:
627
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
628
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
629
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
630
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
631
+ # trigger a retry.
632
+ # @return [::Hash]
633
+ # @!attribute [rw] quota_project
634
+ # A separate project against which to charge quota.
635
+ # @return [::String]
636
+ #
637
+ class Configuration
638
+ extend ::Gapic::Config
639
+
640
+ config_attr :endpoint, "dialogflow.googleapis.com", ::String
641
+ config_attr :credentials, nil do |value|
642
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
643
+ allowed.any? { |klass| klass === value }
644
+ end
645
+ config_attr :scope, nil, ::String, ::Array, nil
646
+ config_attr :lib_name, nil, ::String, nil
647
+ config_attr :lib_version, nil, ::String, nil
648
+ config_attr :timeout, nil, ::Numeric, nil
649
+ config_attr :metadata, nil, ::Hash, nil
650
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
651
+ config_attr :quota_project, nil, ::String, nil
652
+
653
+ # @private
654
+ # Overrides for http bindings for the RPCs of this service
655
+ # are only used when this service is used as mixin, and only
656
+ # by the host service.
657
+ # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
658
+ config_attr :bindings_override, {}, ::Hash, nil
659
+
660
+ # @private
661
+ def initialize parent_config = nil
662
+ @parent_config = parent_config unless parent_config.nil?
663
+
664
+ yield self if block_given?
665
+ end
666
+
667
+ ##
668
+ # Configurations for individual RPCs
669
+ # @return [Rpcs]
670
+ #
671
+ def rpcs
672
+ @rpcs ||= begin
673
+ parent_rpcs = nil
674
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
675
+ Rpcs.new parent_rpcs
676
+ end
677
+ end
678
+
679
+ ##
680
+ # Configuration RPC class for the Contexts API.
681
+ #
682
+ # Includes fields providing the configuration for each RPC in this service.
683
+ # Each configuration object is of type `Gapic::Config::Method` and includes
684
+ # the following configuration fields:
685
+ #
686
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
687
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
688
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
689
+ # include the following keys:
690
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
691
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
692
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
693
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
694
+ # trigger a retry.
695
+ #
696
+ class Rpcs
697
+ ##
698
+ # RPC-specific configuration for `list_contexts`
699
+ # @return [::Gapic::Config::Method]
700
+ #
701
+ attr_reader :list_contexts
702
+ ##
703
+ # RPC-specific configuration for `get_context`
704
+ # @return [::Gapic::Config::Method]
705
+ #
706
+ attr_reader :get_context
707
+ ##
708
+ # RPC-specific configuration for `create_context`
709
+ # @return [::Gapic::Config::Method]
710
+ #
711
+ attr_reader :create_context
712
+ ##
713
+ # RPC-specific configuration for `update_context`
714
+ # @return [::Gapic::Config::Method]
715
+ #
716
+ attr_reader :update_context
717
+ ##
718
+ # RPC-specific configuration for `delete_context`
719
+ # @return [::Gapic::Config::Method]
720
+ #
721
+ attr_reader :delete_context
722
+ ##
723
+ # RPC-specific configuration for `delete_all_contexts`
724
+ # @return [::Gapic::Config::Method]
725
+ #
726
+ attr_reader :delete_all_contexts
727
+
728
+ # @private
729
+ def initialize parent_rpcs = nil
730
+ list_contexts_config = parent_rpcs.list_contexts if parent_rpcs.respond_to? :list_contexts
731
+ @list_contexts = ::Gapic::Config::Method.new list_contexts_config
732
+ get_context_config = parent_rpcs.get_context if parent_rpcs.respond_to? :get_context
733
+ @get_context = ::Gapic::Config::Method.new get_context_config
734
+ create_context_config = parent_rpcs.create_context if parent_rpcs.respond_to? :create_context
735
+ @create_context = ::Gapic::Config::Method.new create_context_config
736
+ update_context_config = parent_rpcs.update_context if parent_rpcs.respond_to? :update_context
737
+ @update_context = ::Gapic::Config::Method.new update_context_config
738
+ delete_context_config = parent_rpcs.delete_context if parent_rpcs.respond_to? :delete_context
739
+ @delete_context = ::Gapic::Config::Method.new delete_context_config
740
+ delete_all_contexts_config = parent_rpcs.delete_all_contexts if parent_rpcs.respond_to? :delete_all_contexts
741
+ @delete_all_contexts = ::Gapic::Config::Method.new delete_all_contexts_config
742
+
743
+ yield self if block_given?
744
+ end
745
+ end
746
+ end
747
+ end
748
+ end
749
+ end
750
+ end
751
+ end
752
+ end
753
+ end