google-cloud-discovery_engine-v1 0.1.0 → 0.3.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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/google/cloud/discovery_engine/v1/completion_service/client.rb +33 -4
  4. data/lib/google/cloud/discovery_engine/v1/completion_service/rest/client.rb +39 -3
  5. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/client.rb +968 -0
  6. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/credentials.rb +47 -0
  7. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/paths.rb +176 -0
  8. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/rest/client.rb +897 -0
  9. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/rest/service_stub.rb +450 -0
  10. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/rest.rb +52 -0
  11. data/lib/google/cloud/discovery_engine/v1/conversational_search_service.rb +55 -0
  12. data/lib/google/cloud/discovery_engine/v1/document_service/client.rb +33 -9
  13. data/lib/google/cloud/discovery_engine/v1/document_service/operations.rb +10 -1
  14. data/lib/google/cloud/discovery_engine/v1/document_service/rest/client.rb +153 -8
  15. data/lib/google/cloud/discovery_engine/v1/document_service/rest/operations.rb +117 -0
  16. data/lib/google/cloud/discovery_engine/v1/rest.rb +2 -1
  17. data/lib/google/cloud/discovery_engine/v1/schema_service/client.rb +24 -1
  18. data/lib/google/cloud/discovery_engine/v1/schema_service/operations.rb +10 -1
  19. data/lib/google/cloud/discovery_engine/v1/schema_service/rest/client.rb +119 -0
  20. data/lib/google/cloud/discovery_engine/v1/schema_service/rest/operations.rb +117 -0
  21. data/lib/google/cloud/discovery_engine/v1/search_service/client.rb +55 -10
  22. data/lib/google/cloud/discovery_engine/v1/search_service/rest/client.rb +67 -12
  23. data/lib/google/cloud/discovery_engine/v1/user_event_service/client.rb +29 -6
  24. data/lib/google/cloud/discovery_engine/v1/user_event_service/operations.rb +10 -1
  25. data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/client.rb +74 -5
  26. data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/operations.rb +117 -0
  27. data/lib/google/cloud/discovery_engine/v1/version.rb +1 -1
  28. data/lib/google/cloud/discovery_engine/v1.rb +2 -1
  29. data/lib/google/cloud/discoveryengine/v1/common_pb.rb +2 -1
  30. data/lib/google/cloud/discoveryengine/v1/completion_service_pb.rb +1 -1
  31. data/lib/google/cloud/discoveryengine/v1/conversation_pb.rb +54 -0
  32. data/lib/google/cloud/discoveryengine/v1/conversational_search_service_pb.rb +61 -0
  33. data/lib/google/cloud/discoveryengine/v1/conversational_search_service_services_pb.rb +67 -0
  34. data/lib/google/cloud/discoveryengine/v1/import_config_pb.rb +1 -1
  35. data/lib/google/cloud/discoveryengine/v1/search_service_pb.rb +13 -1
  36. data/lib/google/cloud/discoveryengine/v1/user_event_pb.rb +1 -1
  37. data/lib/google/cloud/discoveryengine/v1/user_event_service_services_pb.rb +1 -1
  38. data/proto_docs/google/api/field_behavior.rb +14 -0
  39. data/proto_docs/google/cloud/discoveryengine/v1/common.rb +19 -2
  40. data/proto_docs/google/cloud/discoveryengine/v1/completion_service.rb +15 -2
  41. data/proto_docs/google/cloud/discoveryengine/v1/conversation.rb +113 -0
  42. data/proto_docs/google/cloud/discoveryengine/v1/conversational_search_service.rb +206 -0
  43. data/proto_docs/google/cloud/discoveryengine/v1/document.rb +8 -5
  44. data/proto_docs/google/cloud/discoveryengine/v1/document_service.rb +4 -3
  45. data/proto_docs/google/cloud/discoveryengine/v1/import_config.rb +23 -19
  46. data/proto_docs/google/cloud/discoveryengine/v1/search_service.rb +455 -19
  47. data/proto_docs/google/cloud/discoveryengine/v1/user_event.rb +44 -32
  48. data/proto_docs/google/cloud/discoveryengine/v1/user_event_service.rb +1 -1
  49. data/proto_docs/google/protobuf/field_mask.rb +229 -0
  50. metadata +38 -5
@@ -0,0 +1,897 @@
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/discoveryengine/v1/conversational_search_service_pb"
21
+ require "google/cloud/discovery_engine/v1/conversational_search_service/rest/service_stub"
22
+ require "google/cloud/location/rest"
23
+
24
+ module Google
25
+ module Cloud
26
+ module DiscoveryEngine
27
+ module V1
28
+ module ConversationalSearchService
29
+ module Rest
30
+ ##
31
+ # REST client for the ConversationalSearchService service.
32
+ #
33
+ # Service for conversational search.
34
+ #
35
+ class Client
36
+ include Paths
37
+
38
+ # @private
39
+ attr_reader :conversational_search_service_stub
40
+
41
+ ##
42
+ # Configure the ConversationalSearchService Client class.
43
+ #
44
+ # See {::Google::Cloud::DiscoveryEngine::V1::ConversationalSearchService::Rest::Client::Configuration}
45
+ # for a description of the configuration fields.
46
+ #
47
+ # @example
48
+ #
49
+ # # Modify the configuration for all ConversationalSearchService clients
50
+ # ::Google::Cloud::DiscoveryEngine::V1::ConversationalSearchService::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", "DiscoveryEngine", "V1"]
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 = 30.0
71
+ default_config.retry_policy = {
72
+ initial_delay: 1.0, max_delay: 10.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 ConversationalSearchService 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::DiscoveryEngine::V1::ConversationalSearchService::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 ConversationalSearchService REST client object.
103
+ #
104
+ # @example
105
+ #
106
+ # # Create a client using the default configuration
107
+ # client = ::Google::Cloud::DiscoveryEngine::V1::ConversationalSearchService::Rest::Client.new
108
+ #
109
+ # # Create a client using a custom configuration
110
+ # client = ::Google::Cloud::DiscoveryEngine::V1::ConversationalSearchService::Rest::Client.new do |config|
111
+ # config.timeout = 10.0
112
+ # end
113
+ #
114
+ # @yield [config] Configure the ConversationalSearchService 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 == Configuration::DEFAULT_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
+ end
144
+
145
+ @conversational_search_service_stub = ::Google::Cloud::DiscoveryEngine::V1::ConversationalSearchService::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
146
+ end
147
+
148
+ ##
149
+ # Get the associated client for mix-in of the Locations.
150
+ #
151
+ # @return [Google::Cloud::Location::Locations::Rest::Client]
152
+ #
153
+ attr_reader :location_client
154
+
155
+ # Service calls
156
+
157
+ ##
158
+ # Converses a conversation.
159
+ #
160
+ # @overload converse_conversation(request, options = nil)
161
+ # Pass arguments to `converse_conversation` via a request object, either of type
162
+ # {::Google::Cloud::DiscoveryEngine::V1::ConverseConversationRequest} or an equivalent Hash.
163
+ #
164
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::ConverseConversationRequest, ::Hash]
165
+ # A request object representing the call parameters. Required. To specify no
166
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
167
+ # @param options [::Gapic::CallOptions, ::Hash]
168
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
169
+ #
170
+ # @overload converse_conversation(name: nil, query: nil, serving_config: nil, conversation: nil, safe_search: nil, user_labels: nil, summary_spec: nil)
171
+ # Pass arguments to `converse_conversation` via keyword arguments. Note that at
172
+ # least one keyword argument is required. To specify no parameters, or to keep all
173
+ # the default parameter values, pass an empty Hash as a request object (see above).
174
+ #
175
+ # @param name [::String]
176
+ # Required. The resource name of the Conversation to get. Format:
177
+ # `projects/{project_number}/locations/{location_id}/collections/{collection}/dataStores/{data_store_id}/conversations/{conversation_id}`.
178
+ # Use
179
+ # `projects/{project_number}/locations/{location_id}/collections/{collection}/dataStores/{data_store_id}/conversations/-`
180
+ # to activate auto session mode, which automatically creates a new
181
+ # conversation inside a ConverseConversation session.
182
+ # @param query [::Google::Cloud::DiscoveryEngine::V1::TextInput, ::Hash]
183
+ # Required. Current user input.
184
+ # @param serving_config [::String]
185
+ # The resource name of the Serving Config to use. Format:
186
+ # `projects/{project_number}/locations/{location_id}/collections/{collection}/dataStores/{data_store_id}/servingConfigs/{serving_config_id}`
187
+ # If this is not set, the default serving config will be used.
188
+ # @param conversation [::Google::Cloud::DiscoveryEngine::V1::Conversation, ::Hash]
189
+ # The conversation to be used by auto session only. The name field will be
190
+ # ignored as we automatically assign new name for the conversation in auto
191
+ # session.
192
+ # @param safe_search [::Boolean]
193
+ # Whether to turn on safe search.
194
+ # @param user_labels [::Hash{::String => ::String}]
195
+ # The user labels applied to a resource must meet the following requirements:
196
+ #
197
+ # * Each resource can have multiple labels, up to a maximum of 64.
198
+ # * Each label must be a key-value pair.
199
+ # * Keys have a minimum length of 1 character and a maximum length of 63
200
+ # characters and cannot be empty. Values can be empty and have a maximum
201
+ # length of 63 characters.
202
+ # * Keys and values can contain only lowercase letters, numeric characters,
203
+ # underscores, and dashes. All characters must use UTF-8 encoding, and
204
+ # international characters are allowed.
205
+ # * The key portion of a label must be unique. However, you can use the same
206
+ # key with multiple resources.
207
+ # * Keys must start with a lowercase letter or international character.
208
+ #
209
+ # See [Google Cloud
210
+ # Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements)
211
+ # for more details.
212
+ # @param summary_spec [::Google::Cloud::DiscoveryEngine::V1::SearchRequest::ContentSearchSpec::SummarySpec, ::Hash]
213
+ # A specification for configuring the summary returned in the response.
214
+ # @yield [result, operation] Access the result along with the TransportOperation object
215
+ # @yieldparam result [::Google::Cloud::DiscoveryEngine::V1::ConverseConversationResponse]
216
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
217
+ #
218
+ # @return [::Google::Cloud::DiscoveryEngine::V1::ConverseConversationResponse]
219
+ #
220
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
221
+ #
222
+ # @example Basic example
223
+ # require "google/cloud/discovery_engine/v1"
224
+ #
225
+ # # Create a client object. The client can be reused for multiple calls.
226
+ # client = Google::Cloud::DiscoveryEngine::V1::ConversationalSearchService::Rest::Client.new
227
+ #
228
+ # # Create a request. To set request fields, pass in keyword arguments.
229
+ # request = Google::Cloud::DiscoveryEngine::V1::ConverseConversationRequest.new
230
+ #
231
+ # # Call the converse_conversation method.
232
+ # result = client.converse_conversation request
233
+ #
234
+ # # The returned object is of type Google::Cloud::DiscoveryEngine::V1::ConverseConversationResponse.
235
+ # p result
236
+ #
237
+ def converse_conversation request, options = nil
238
+ raise ::ArgumentError, "request must be provided" if request.nil?
239
+
240
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::ConverseConversationRequest
241
+
242
+ # Converts hash and nil to an options object
243
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
244
+
245
+ # Customize the options with defaults
246
+ call_metadata = @config.rpcs.converse_conversation.metadata.to_h
247
+
248
+ # Set x-goog-api-client and x-goog-user-project headers
249
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
250
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
251
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION,
252
+ transports_version_send: [:rest]
253
+
254
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
255
+
256
+ options.apply_defaults timeout: @config.rpcs.converse_conversation.timeout,
257
+ metadata: call_metadata,
258
+ retry_policy: @config.rpcs.converse_conversation.retry_policy
259
+
260
+ options.apply_defaults timeout: @config.timeout,
261
+ metadata: @config.metadata,
262
+ retry_policy: @config.retry_policy
263
+
264
+ @conversational_search_service_stub.converse_conversation request, options do |result, operation|
265
+ yield result, operation if block_given?
266
+ return result
267
+ end
268
+ rescue ::Gapic::Rest::Error => e
269
+ raise ::Google::Cloud::Error.from_error(e)
270
+ end
271
+
272
+ ##
273
+ # Creates a Conversation.
274
+ #
275
+ # If the {::Google::Cloud::DiscoveryEngine::V1::Conversation Conversation} to
276
+ # create already exists, an ALREADY_EXISTS error is returned.
277
+ #
278
+ # @overload create_conversation(request, options = nil)
279
+ # Pass arguments to `create_conversation` via a request object, either of type
280
+ # {::Google::Cloud::DiscoveryEngine::V1::CreateConversationRequest} or an equivalent Hash.
281
+ #
282
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::CreateConversationRequest, ::Hash]
283
+ # A request object representing the call parameters. Required. To specify no
284
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
285
+ # @param options [::Gapic::CallOptions, ::Hash]
286
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
287
+ #
288
+ # @overload create_conversation(parent: nil, conversation: nil)
289
+ # Pass arguments to `create_conversation` via keyword arguments. Note that at
290
+ # least one keyword argument is required. To specify no parameters, or to keep all
291
+ # the default parameter values, pass an empty Hash as a request object (see above).
292
+ #
293
+ # @param parent [::String]
294
+ # Required. Full resource name of parent data store. Format:
295
+ # `projects/{project_number}/locations/{location_id}/collections/{collection}/dataStores/{data_store_id}`
296
+ # @param conversation [::Google::Cloud::DiscoveryEngine::V1::Conversation, ::Hash]
297
+ # Required. The conversation to create.
298
+ # @yield [result, operation] Access the result along with the TransportOperation object
299
+ # @yieldparam result [::Google::Cloud::DiscoveryEngine::V1::Conversation]
300
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
301
+ #
302
+ # @return [::Google::Cloud::DiscoveryEngine::V1::Conversation]
303
+ #
304
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
305
+ #
306
+ # @example Basic example
307
+ # require "google/cloud/discovery_engine/v1"
308
+ #
309
+ # # Create a client object. The client can be reused for multiple calls.
310
+ # client = Google::Cloud::DiscoveryEngine::V1::ConversationalSearchService::Rest::Client.new
311
+ #
312
+ # # Create a request. To set request fields, pass in keyword arguments.
313
+ # request = Google::Cloud::DiscoveryEngine::V1::CreateConversationRequest.new
314
+ #
315
+ # # Call the create_conversation method.
316
+ # result = client.create_conversation request
317
+ #
318
+ # # The returned object is of type Google::Cloud::DiscoveryEngine::V1::Conversation.
319
+ # p result
320
+ #
321
+ def create_conversation request, options = nil
322
+ raise ::ArgumentError, "request must be provided" if request.nil?
323
+
324
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::CreateConversationRequest
325
+
326
+ # Converts hash and nil to an options object
327
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
328
+
329
+ # Customize the options with defaults
330
+ call_metadata = @config.rpcs.create_conversation.metadata.to_h
331
+
332
+ # Set x-goog-api-client and x-goog-user-project headers
333
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
334
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
335
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION,
336
+ transports_version_send: [:rest]
337
+
338
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
339
+
340
+ options.apply_defaults timeout: @config.rpcs.create_conversation.timeout,
341
+ metadata: call_metadata,
342
+ retry_policy: @config.rpcs.create_conversation.retry_policy
343
+
344
+ options.apply_defaults timeout: @config.timeout,
345
+ metadata: @config.metadata,
346
+ retry_policy: @config.retry_policy
347
+
348
+ @conversational_search_service_stub.create_conversation request, options do |result, operation|
349
+ yield result, operation if block_given?
350
+ return result
351
+ end
352
+ rescue ::Gapic::Rest::Error => e
353
+ raise ::Google::Cloud::Error.from_error(e)
354
+ end
355
+
356
+ ##
357
+ # Deletes a Conversation.
358
+ #
359
+ # If the {::Google::Cloud::DiscoveryEngine::V1::Conversation Conversation} to
360
+ # delete does not exist, a NOT_FOUND error is returned.
361
+ #
362
+ # @overload delete_conversation(request, options = nil)
363
+ # Pass arguments to `delete_conversation` via a request object, either of type
364
+ # {::Google::Cloud::DiscoveryEngine::V1::DeleteConversationRequest} or an equivalent Hash.
365
+ #
366
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::DeleteConversationRequest, ::Hash]
367
+ # A request object representing the call parameters. Required. To specify no
368
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
369
+ # @param options [::Gapic::CallOptions, ::Hash]
370
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
371
+ #
372
+ # @overload delete_conversation(name: nil)
373
+ # Pass arguments to `delete_conversation` via keyword arguments. Note that at
374
+ # least one keyword argument is required. To specify no parameters, or to keep all
375
+ # the default parameter values, pass an empty Hash as a request object (see above).
376
+ #
377
+ # @param name [::String]
378
+ # Required. The resource name of the Conversation to delete. Format:
379
+ # `projects/{project_number}/locations/{location_id}/collections/{collection}/dataStores/{data_store_id}/conversations/{conversation_id}`
380
+ # @yield [result, operation] Access the result along with the TransportOperation object
381
+ # @yieldparam result [::Google::Protobuf::Empty]
382
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
383
+ #
384
+ # @return [::Google::Protobuf::Empty]
385
+ #
386
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
387
+ #
388
+ # @example Basic example
389
+ # require "google/cloud/discovery_engine/v1"
390
+ #
391
+ # # Create a client object. The client can be reused for multiple calls.
392
+ # client = Google::Cloud::DiscoveryEngine::V1::ConversationalSearchService::Rest::Client.new
393
+ #
394
+ # # Create a request. To set request fields, pass in keyword arguments.
395
+ # request = Google::Cloud::DiscoveryEngine::V1::DeleteConversationRequest.new
396
+ #
397
+ # # Call the delete_conversation method.
398
+ # result = client.delete_conversation request
399
+ #
400
+ # # The returned object is of type Google::Protobuf::Empty.
401
+ # p result
402
+ #
403
+ def delete_conversation request, options = nil
404
+ raise ::ArgumentError, "request must be provided" if request.nil?
405
+
406
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::DeleteConversationRequest
407
+
408
+ # Converts hash and nil to an options object
409
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
410
+
411
+ # Customize the options with defaults
412
+ call_metadata = @config.rpcs.delete_conversation.metadata.to_h
413
+
414
+ # Set x-goog-api-client and x-goog-user-project headers
415
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
416
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
417
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION,
418
+ transports_version_send: [:rest]
419
+
420
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
421
+
422
+ options.apply_defaults timeout: @config.rpcs.delete_conversation.timeout,
423
+ metadata: call_metadata,
424
+ retry_policy: @config.rpcs.delete_conversation.retry_policy
425
+
426
+ options.apply_defaults timeout: @config.timeout,
427
+ metadata: @config.metadata,
428
+ retry_policy: @config.retry_policy
429
+
430
+ @conversational_search_service_stub.delete_conversation request, options do |result, operation|
431
+ yield result, operation if block_given?
432
+ return result
433
+ end
434
+ rescue ::Gapic::Rest::Error => e
435
+ raise ::Google::Cloud::Error.from_error(e)
436
+ end
437
+
438
+ ##
439
+ # Updates a Conversation.
440
+ #
441
+ # {::Google::Cloud::DiscoveryEngine::V1::Conversation Conversation} action type
442
+ # cannot be changed. If the
443
+ # {::Google::Cloud::DiscoveryEngine::V1::Conversation Conversation} to update does
444
+ # not exist, a NOT_FOUND error is returned.
445
+ #
446
+ # @overload update_conversation(request, options = nil)
447
+ # Pass arguments to `update_conversation` via a request object, either of type
448
+ # {::Google::Cloud::DiscoveryEngine::V1::UpdateConversationRequest} or an equivalent Hash.
449
+ #
450
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::UpdateConversationRequest, ::Hash]
451
+ # A request object representing the call parameters. Required. To specify no
452
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
453
+ # @param options [::Gapic::CallOptions, ::Hash]
454
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
455
+ #
456
+ # @overload update_conversation(conversation: nil, update_mask: nil)
457
+ # Pass arguments to `update_conversation` via keyword arguments. Note that at
458
+ # least one keyword argument is required. To specify no parameters, or to keep all
459
+ # the default parameter values, pass an empty Hash as a request object (see above).
460
+ #
461
+ # @param conversation [::Google::Cloud::DiscoveryEngine::V1::Conversation, ::Hash]
462
+ # Required. The Conversation to update.
463
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
464
+ # Indicates which fields in the provided
465
+ # {::Google::Cloud::DiscoveryEngine::V1::Conversation Conversation} to update. The
466
+ # following are NOT supported:
467
+ #
468
+ # * [conversation.name][]
469
+ #
470
+ # If not set or empty, all supported fields are updated.
471
+ # @yield [result, operation] Access the result along with the TransportOperation object
472
+ # @yieldparam result [::Google::Cloud::DiscoveryEngine::V1::Conversation]
473
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
474
+ #
475
+ # @return [::Google::Cloud::DiscoveryEngine::V1::Conversation]
476
+ #
477
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
478
+ #
479
+ # @example Basic example
480
+ # require "google/cloud/discovery_engine/v1"
481
+ #
482
+ # # Create a client object. The client can be reused for multiple calls.
483
+ # client = Google::Cloud::DiscoveryEngine::V1::ConversationalSearchService::Rest::Client.new
484
+ #
485
+ # # Create a request. To set request fields, pass in keyword arguments.
486
+ # request = Google::Cloud::DiscoveryEngine::V1::UpdateConversationRequest.new
487
+ #
488
+ # # Call the update_conversation method.
489
+ # result = client.update_conversation request
490
+ #
491
+ # # The returned object is of type Google::Cloud::DiscoveryEngine::V1::Conversation.
492
+ # p result
493
+ #
494
+ def update_conversation request, options = nil
495
+ raise ::ArgumentError, "request must be provided" if request.nil?
496
+
497
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::UpdateConversationRequest
498
+
499
+ # Converts hash and nil to an options object
500
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
501
+
502
+ # Customize the options with defaults
503
+ call_metadata = @config.rpcs.update_conversation.metadata.to_h
504
+
505
+ # Set x-goog-api-client and x-goog-user-project headers
506
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
507
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
508
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION,
509
+ transports_version_send: [:rest]
510
+
511
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
512
+
513
+ options.apply_defaults timeout: @config.rpcs.update_conversation.timeout,
514
+ metadata: call_metadata,
515
+ retry_policy: @config.rpcs.update_conversation.retry_policy
516
+
517
+ options.apply_defaults timeout: @config.timeout,
518
+ metadata: @config.metadata,
519
+ retry_policy: @config.retry_policy
520
+
521
+ @conversational_search_service_stub.update_conversation request, options do |result, operation|
522
+ yield result, operation if block_given?
523
+ return result
524
+ end
525
+ rescue ::Gapic::Rest::Error => e
526
+ raise ::Google::Cloud::Error.from_error(e)
527
+ end
528
+
529
+ ##
530
+ # Gets a Conversation.
531
+ #
532
+ # @overload get_conversation(request, options = nil)
533
+ # Pass arguments to `get_conversation` via a request object, either of type
534
+ # {::Google::Cloud::DiscoveryEngine::V1::GetConversationRequest} or an equivalent Hash.
535
+ #
536
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::GetConversationRequest, ::Hash]
537
+ # A request object representing the call parameters. Required. To specify no
538
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
539
+ # @param options [::Gapic::CallOptions, ::Hash]
540
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
541
+ #
542
+ # @overload get_conversation(name: nil)
543
+ # Pass arguments to `get_conversation` via keyword arguments. Note that at
544
+ # least one keyword argument is required. To specify no parameters, or to keep all
545
+ # the default parameter values, pass an empty Hash as a request object (see above).
546
+ #
547
+ # @param name [::String]
548
+ # Required. The resource name of the Conversation to get. Format:
549
+ # `projects/{project_number}/locations/{location_id}/collections/{collection}/dataStores/{data_store_id}/conversations/{conversation_id}`
550
+ # @yield [result, operation] Access the result along with the TransportOperation object
551
+ # @yieldparam result [::Google::Cloud::DiscoveryEngine::V1::Conversation]
552
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
553
+ #
554
+ # @return [::Google::Cloud::DiscoveryEngine::V1::Conversation]
555
+ #
556
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
557
+ #
558
+ # @example Basic example
559
+ # require "google/cloud/discovery_engine/v1"
560
+ #
561
+ # # Create a client object. The client can be reused for multiple calls.
562
+ # client = Google::Cloud::DiscoveryEngine::V1::ConversationalSearchService::Rest::Client.new
563
+ #
564
+ # # Create a request. To set request fields, pass in keyword arguments.
565
+ # request = Google::Cloud::DiscoveryEngine::V1::GetConversationRequest.new
566
+ #
567
+ # # Call the get_conversation method.
568
+ # result = client.get_conversation request
569
+ #
570
+ # # The returned object is of type Google::Cloud::DiscoveryEngine::V1::Conversation.
571
+ # p result
572
+ #
573
+ def get_conversation request, options = nil
574
+ raise ::ArgumentError, "request must be provided" if request.nil?
575
+
576
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::GetConversationRequest
577
+
578
+ # Converts hash and nil to an options object
579
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
580
+
581
+ # Customize the options with defaults
582
+ call_metadata = @config.rpcs.get_conversation.metadata.to_h
583
+
584
+ # Set x-goog-api-client and x-goog-user-project headers
585
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
586
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
587
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION,
588
+ transports_version_send: [:rest]
589
+
590
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
591
+
592
+ options.apply_defaults timeout: @config.rpcs.get_conversation.timeout,
593
+ metadata: call_metadata,
594
+ retry_policy: @config.rpcs.get_conversation.retry_policy
595
+
596
+ options.apply_defaults timeout: @config.timeout,
597
+ metadata: @config.metadata,
598
+ retry_policy: @config.retry_policy
599
+
600
+ @conversational_search_service_stub.get_conversation request, options do |result, operation|
601
+ yield result, operation if block_given?
602
+ return result
603
+ end
604
+ rescue ::Gapic::Rest::Error => e
605
+ raise ::Google::Cloud::Error.from_error(e)
606
+ end
607
+
608
+ ##
609
+ # Lists all Conversations by their parent
610
+ # [DataStore][google.cloud.discoveryengine.v1.DataStore].
611
+ #
612
+ # @overload list_conversations(request, options = nil)
613
+ # Pass arguments to `list_conversations` via a request object, either of type
614
+ # {::Google::Cloud::DiscoveryEngine::V1::ListConversationsRequest} or an equivalent Hash.
615
+ #
616
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::ListConversationsRequest, ::Hash]
617
+ # A request object representing the call parameters. Required. To specify no
618
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
619
+ # @param options [::Gapic::CallOptions, ::Hash]
620
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
621
+ #
622
+ # @overload list_conversations(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil)
623
+ # Pass arguments to `list_conversations` via keyword arguments. Note that at
624
+ # least one keyword argument is required. To specify no parameters, or to keep all
625
+ # the default parameter values, pass an empty Hash as a request object (see above).
626
+ #
627
+ # @param parent [::String]
628
+ # Required. The data store resource name. Format:
629
+ # `projects/{project_number}/locations/{location_id}/collections/{collection}/dataStores/{data_store_id}`
630
+ # @param page_size [::Integer]
631
+ # Maximum number of results to return. If unspecified, defaults
632
+ # to 50. Max allowed value is 1000.
633
+ # @param page_token [::String]
634
+ # A page token, received from a previous `ListConversations` call.
635
+ # Provide this to retrieve the subsequent page.
636
+ # @param filter [::String]
637
+ # A filter to apply on the list results. The supported features are:
638
+ # user_pseudo_id, state.
639
+ #
640
+ # Example:
641
+ # "user_pseudo_id = some_id"
642
+ # @param order_by [::String]
643
+ # A comma-separated list of fields to order by, sorted in ascending order.
644
+ # Use "desc" after a field name for descending.
645
+ # Supported fields:
646
+ # * `update_time`
647
+ # * `create_time`
648
+ # * `conversation_name`
649
+ #
650
+ # Example:
651
+ # "update_time desc"
652
+ # "create_time"
653
+ # @yield [result, operation] Access the result along with the TransportOperation object
654
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::DiscoveryEngine::V1::Conversation>]
655
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
656
+ #
657
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::DiscoveryEngine::V1::Conversation>]
658
+ #
659
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
660
+ #
661
+ # @example Basic example
662
+ # require "google/cloud/discovery_engine/v1"
663
+ #
664
+ # # Create a client object. The client can be reused for multiple calls.
665
+ # client = Google::Cloud::DiscoveryEngine::V1::ConversationalSearchService::Rest::Client.new
666
+ #
667
+ # # Create a request. To set request fields, pass in keyword arguments.
668
+ # request = Google::Cloud::DiscoveryEngine::V1::ListConversationsRequest.new
669
+ #
670
+ # # Call the list_conversations method.
671
+ # result = client.list_conversations request
672
+ #
673
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
674
+ # # over elements, and API calls will be issued to fetch pages as needed.
675
+ # result.each do |item|
676
+ # # Each element is of type ::Google::Cloud::DiscoveryEngine::V1::Conversation.
677
+ # p item
678
+ # end
679
+ #
680
+ def list_conversations request, options = nil
681
+ raise ::ArgumentError, "request must be provided" if request.nil?
682
+
683
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::ListConversationsRequest
684
+
685
+ # Converts hash and nil to an options object
686
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
687
+
688
+ # Customize the options with defaults
689
+ call_metadata = @config.rpcs.list_conversations.metadata.to_h
690
+
691
+ # Set x-goog-api-client and x-goog-user-project headers
692
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
693
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
694
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION,
695
+ transports_version_send: [:rest]
696
+
697
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
698
+
699
+ options.apply_defaults timeout: @config.rpcs.list_conversations.timeout,
700
+ metadata: call_metadata,
701
+ retry_policy: @config.rpcs.list_conversations.retry_policy
702
+
703
+ options.apply_defaults timeout: @config.timeout,
704
+ metadata: @config.metadata,
705
+ retry_policy: @config.retry_policy
706
+
707
+ @conversational_search_service_stub.list_conversations request, options do |result, operation|
708
+ result = ::Gapic::Rest::PagedEnumerable.new @conversational_search_service_stub, :list_conversations, "conversations", request, result, options
709
+ yield result, operation if block_given?
710
+ return result
711
+ end
712
+ rescue ::Gapic::Rest::Error => e
713
+ raise ::Google::Cloud::Error.from_error(e)
714
+ end
715
+
716
+ ##
717
+ # Configuration class for the ConversationalSearchService REST API.
718
+ #
719
+ # This class represents the configuration for ConversationalSearchService REST,
720
+ # providing control over timeouts, retry behavior, logging, transport
721
+ # parameters, and other low-level controls. Certain parameters can also be
722
+ # applied individually to specific RPCs. See
723
+ # {::Google::Cloud::DiscoveryEngine::V1::ConversationalSearchService::Rest::Client::Configuration::Rpcs}
724
+ # for a list of RPCs that can be configured independently.
725
+ #
726
+ # Configuration can be applied globally to all clients, or to a single client
727
+ # on construction.
728
+ #
729
+ # @example
730
+ #
731
+ # # Modify the global config, setting the timeout for
732
+ # # converse_conversation to 20 seconds,
733
+ # # and all remaining timeouts to 10 seconds.
734
+ # ::Google::Cloud::DiscoveryEngine::V1::ConversationalSearchService::Rest::Client.configure do |config|
735
+ # config.timeout = 10.0
736
+ # config.rpcs.converse_conversation.timeout = 20.0
737
+ # end
738
+ #
739
+ # # Apply the above configuration only to a new client.
740
+ # client = ::Google::Cloud::DiscoveryEngine::V1::ConversationalSearchService::Rest::Client.new do |config|
741
+ # config.timeout = 10.0
742
+ # config.rpcs.converse_conversation.timeout = 20.0
743
+ # end
744
+ #
745
+ # @!attribute [rw] endpoint
746
+ # The hostname or hostname:port of the service endpoint.
747
+ # Defaults to `"discoveryengine.googleapis.com"`.
748
+ # @return [::String]
749
+ # @!attribute [rw] credentials
750
+ # Credentials to send with calls. You may provide any of the following types:
751
+ # * (`String`) The path to a service account key file in JSON format
752
+ # * (`Hash`) A service account key as a Hash
753
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
754
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
755
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
756
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
757
+ # * (`nil`) indicating no credentials
758
+ # @return [::Object]
759
+ # @!attribute [rw] scope
760
+ # The OAuth scopes
761
+ # @return [::Array<::String>]
762
+ # @!attribute [rw] lib_name
763
+ # The library name as recorded in instrumentation and logging
764
+ # @return [::String]
765
+ # @!attribute [rw] lib_version
766
+ # The library version as recorded in instrumentation and logging
767
+ # @return [::String]
768
+ # @!attribute [rw] timeout
769
+ # The call timeout in seconds.
770
+ # @return [::Numeric]
771
+ # @!attribute [rw] metadata
772
+ # Additional headers to be sent with the call.
773
+ # @return [::Hash{::Symbol=>::String}]
774
+ # @!attribute [rw] retry_policy
775
+ # The retry policy. The value is a hash with the following keys:
776
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
777
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
778
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
779
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
780
+ # trigger a retry.
781
+ # @return [::Hash]
782
+ # @!attribute [rw] quota_project
783
+ # A separate project against which to charge quota.
784
+ # @return [::String]
785
+ #
786
+ class Configuration
787
+ extend ::Gapic::Config
788
+
789
+ DEFAULT_ENDPOINT = "discoveryengine.googleapis.com"
790
+
791
+ config_attr :endpoint, DEFAULT_ENDPOINT, ::String
792
+ config_attr :credentials, nil do |value|
793
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
794
+ allowed.any? { |klass| klass === value }
795
+ end
796
+ config_attr :scope, nil, ::String, ::Array, nil
797
+ config_attr :lib_name, nil, ::String, nil
798
+ config_attr :lib_version, nil, ::String, nil
799
+ config_attr :timeout, nil, ::Numeric, nil
800
+ config_attr :metadata, nil, ::Hash, nil
801
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
802
+ config_attr :quota_project, nil, ::String, nil
803
+
804
+ # @private
805
+ def initialize parent_config = nil
806
+ @parent_config = parent_config unless parent_config.nil?
807
+
808
+ yield self if block_given?
809
+ end
810
+
811
+ ##
812
+ # Configurations for individual RPCs
813
+ # @return [Rpcs]
814
+ #
815
+ def rpcs
816
+ @rpcs ||= begin
817
+ parent_rpcs = nil
818
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
819
+ Rpcs.new parent_rpcs
820
+ end
821
+ end
822
+
823
+ ##
824
+ # Configuration RPC class for the ConversationalSearchService API.
825
+ #
826
+ # Includes fields providing the configuration for each RPC in this service.
827
+ # Each configuration object is of type `Gapic::Config::Method` and includes
828
+ # the following configuration fields:
829
+ #
830
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
831
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
832
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
833
+ # include the following keys:
834
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
835
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
836
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
837
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
838
+ # trigger a retry.
839
+ #
840
+ class Rpcs
841
+ ##
842
+ # RPC-specific configuration for `converse_conversation`
843
+ # @return [::Gapic::Config::Method]
844
+ #
845
+ attr_reader :converse_conversation
846
+ ##
847
+ # RPC-specific configuration for `create_conversation`
848
+ # @return [::Gapic::Config::Method]
849
+ #
850
+ attr_reader :create_conversation
851
+ ##
852
+ # RPC-specific configuration for `delete_conversation`
853
+ # @return [::Gapic::Config::Method]
854
+ #
855
+ attr_reader :delete_conversation
856
+ ##
857
+ # RPC-specific configuration for `update_conversation`
858
+ # @return [::Gapic::Config::Method]
859
+ #
860
+ attr_reader :update_conversation
861
+ ##
862
+ # RPC-specific configuration for `get_conversation`
863
+ # @return [::Gapic::Config::Method]
864
+ #
865
+ attr_reader :get_conversation
866
+ ##
867
+ # RPC-specific configuration for `list_conversations`
868
+ # @return [::Gapic::Config::Method]
869
+ #
870
+ attr_reader :list_conversations
871
+
872
+ # @private
873
+ def initialize parent_rpcs = nil
874
+ converse_conversation_config = parent_rpcs.converse_conversation if parent_rpcs.respond_to? :converse_conversation
875
+ @converse_conversation = ::Gapic::Config::Method.new converse_conversation_config
876
+ create_conversation_config = parent_rpcs.create_conversation if parent_rpcs.respond_to? :create_conversation
877
+ @create_conversation = ::Gapic::Config::Method.new create_conversation_config
878
+ delete_conversation_config = parent_rpcs.delete_conversation if parent_rpcs.respond_to? :delete_conversation
879
+ @delete_conversation = ::Gapic::Config::Method.new delete_conversation_config
880
+ update_conversation_config = parent_rpcs.update_conversation if parent_rpcs.respond_to? :update_conversation
881
+ @update_conversation = ::Gapic::Config::Method.new update_conversation_config
882
+ get_conversation_config = parent_rpcs.get_conversation if parent_rpcs.respond_to? :get_conversation
883
+ @get_conversation = ::Gapic::Config::Method.new get_conversation_config
884
+ list_conversations_config = parent_rpcs.list_conversations if parent_rpcs.respond_to? :list_conversations
885
+ @list_conversations = ::Gapic::Config::Method.new list_conversations_config
886
+
887
+ yield self if block_given?
888
+ end
889
+ end
890
+ end
891
+ end
892
+ end
893
+ end
894
+ end
895
+ end
896
+ end
897
+ end