google-cloud-discovery_engine-v1 2.3.1 → 2.4.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 (38) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +4 -4
  3. data/README.md +4 -4
  4. data/lib/google/cloud/discovery_engine/v1/assistant_service/client.rb +509 -0
  5. data/lib/google/cloud/discovery_engine/v1/assistant_service/credentials.rb +47 -0
  6. data/lib/google/cloud/discovery_engine/v1/assistant_service/paths.rb +169 -0
  7. data/lib/google/cloud/discovery_engine/v1/assistant_service/rest/client.rb +478 -0
  8. data/lib/google/cloud/discovery_engine/v1/assistant_service/rest/service_stub.rb +137 -0
  9. data/lib/google/cloud/discovery_engine/v1/assistant_service/rest.rb +52 -0
  10. data/lib/google/cloud/discovery_engine/v1/assistant_service.rb +55 -0
  11. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/client.rb +16 -4
  12. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/rest/client.rb +16 -4
  13. data/lib/google/cloud/discovery_engine/v1/rest.rb +4 -2
  14. data/lib/google/cloud/discovery_engine/v1/search_service/client.rb +16 -28
  15. data/lib/google/cloud/discovery_engine/v1/search_service/rest/client.rb +16 -28
  16. data/lib/google/cloud/discovery_engine/v1/session_service/client.rb +920 -0
  17. data/lib/google/cloud/discovery_engine/v1/session_service/credentials.rb +47 -0
  18. data/lib/google/cloud/discovery_engine/v1/session_service/paths.rb +330 -0
  19. data/lib/google/cloud/discovery_engine/v1/session_service/rest/client.rb +859 -0
  20. data/lib/google/cloud/discovery_engine/v1/session_service/rest/service_stub.rb +462 -0
  21. data/lib/google/cloud/discovery_engine/v1/session_service/rest.rb +52 -0
  22. data/lib/google/cloud/discovery_engine/v1/session_service.rb +55 -0
  23. data/lib/google/cloud/discovery_engine/v1/version.rb +1 -1
  24. data/lib/google/cloud/discovery_engine/v1.rb +5 -3
  25. data/lib/google/cloud/discoveryengine/v1/assist_answer_pb.rb +59 -0
  26. data/lib/google/cloud/discoveryengine/v1/assistant_pb.rb +45 -0
  27. data/lib/google/cloud/discoveryengine/v1/assistant_service_pb.rb +62 -0
  28. data/lib/google/cloud/discoveryengine/v1/assistant_service_services_pb.rb +45 -0
  29. data/lib/google/cloud/discoveryengine/v1/session_pb.rb +1 -1
  30. data/lib/google/cloud/discoveryengine/v1/session_service_pb.rb +49 -0
  31. data/lib/google/cloud/discoveryengine/v1/session_service_services_pb.rb +64 -0
  32. data/proto_docs/google/cloud/discoveryengine/v1/assist_answer.rb +278 -0
  33. data/proto_docs/google/cloud/discoveryengine/v1/assistant.rb +39 -0
  34. data/proto_docs/google/cloud/discoveryengine/v1/assistant_service.rb +207 -0
  35. data/proto_docs/google/cloud/discoveryengine/v1/conversational_search_service.rb +15 -3
  36. data/proto_docs/google/cloud/discoveryengine/v1/search_service.rb +8 -14
  37. data/proto_docs/google/cloud/discoveryengine/v1/session.rb +20 -4
  38. metadata +24 -1
@@ -0,0 +1,920 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2025 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/session_service_pb"
21
+ require "google/cloud/location"
22
+
23
+ module Google
24
+ module Cloud
25
+ module DiscoveryEngine
26
+ module V1
27
+ module SessionService
28
+ ##
29
+ # Client for the SessionService service.
30
+ #
31
+ # Service for managing Sessions and Session-related resources.
32
+ #
33
+ class Client
34
+ # @private
35
+ API_VERSION = ""
36
+
37
+ # @private
38
+ DEFAULT_ENDPOINT_TEMPLATE = "discoveryengine.$UNIVERSE_DOMAIN$"
39
+
40
+ include Paths
41
+
42
+ # @private
43
+ attr_reader :session_service_stub
44
+
45
+ ##
46
+ # Configure the SessionService Client class.
47
+ #
48
+ # See {::Google::Cloud::DiscoveryEngine::V1::SessionService::Client::Configuration}
49
+ # for a description of the configuration fields.
50
+ #
51
+ # @example
52
+ #
53
+ # # Modify the configuration for all SessionService clients
54
+ # ::Google::Cloud::DiscoveryEngine::V1::SessionService::Client.configure do |config|
55
+ # config.timeout = 10.0
56
+ # end
57
+ #
58
+ # @yield [config] Configure the Client client.
59
+ # @yieldparam config [Client::Configuration]
60
+ #
61
+ # @return [Client::Configuration]
62
+ #
63
+ def self.configure
64
+ @configure ||= begin
65
+ namespace = ["Google", "Cloud", "DiscoveryEngine", "V1"]
66
+ parent_config = while namespace.any?
67
+ parent_name = namespace.join "::"
68
+ parent_const = const_get parent_name
69
+ break parent_const.configure if parent_const.respond_to? :configure
70
+ namespace.pop
71
+ end
72
+ default_config = Client::Configuration.new parent_config
73
+
74
+ default_config.timeout = 30.0
75
+ default_config.retry_policy = {
76
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
77
+ }
78
+
79
+ default_config
80
+ end
81
+ yield @configure if block_given?
82
+ @configure
83
+ end
84
+
85
+ ##
86
+ # Configure the SessionService Client instance.
87
+ #
88
+ # The configuration is set to the derived mode, meaning that values can be changed,
89
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
90
+ # should be made on {Client.configure}.
91
+ #
92
+ # See {::Google::Cloud::DiscoveryEngine::V1::SessionService::Client::Configuration}
93
+ # for a description of the configuration fields.
94
+ #
95
+ # @yield [config] Configure the Client client.
96
+ # @yieldparam config [Client::Configuration]
97
+ #
98
+ # @return [Client::Configuration]
99
+ #
100
+ def configure
101
+ yield @config if block_given?
102
+ @config
103
+ end
104
+
105
+ ##
106
+ # The effective universe domain
107
+ #
108
+ # @return [String]
109
+ #
110
+ def universe_domain
111
+ @session_service_stub.universe_domain
112
+ end
113
+
114
+ ##
115
+ # Create a new SessionService client object.
116
+ #
117
+ # @example
118
+ #
119
+ # # Create a client using the default configuration
120
+ # client = ::Google::Cloud::DiscoveryEngine::V1::SessionService::Client.new
121
+ #
122
+ # # Create a client using a custom configuration
123
+ # client = ::Google::Cloud::DiscoveryEngine::V1::SessionService::Client.new do |config|
124
+ # config.timeout = 10.0
125
+ # end
126
+ #
127
+ # @yield [config] Configure the SessionService client.
128
+ # @yieldparam config [Client::Configuration]
129
+ #
130
+ def initialize
131
+ # These require statements are intentionally placed here to initialize
132
+ # the gRPC module only when it's required.
133
+ # See https://github.com/googleapis/toolkit/issues/446
134
+ require "gapic/grpc"
135
+ require "google/cloud/discoveryengine/v1/session_service_services_pb"
136
+
137
+ # Create the configuration object
138
+ @config = Configuration.new Client.configure
139
+
140
+ # Yield the configuration if needed
141
+ yield @config if block_given?
142
+
143
+ # Create credentials
144
+ credentials = @config.credentials
145
+ # Use self-signed JWT if the endpoint is unchanged from default,
146
+ # but only if the default endpoint does not have a region prefix.
147
+ enable_self_signed_jwt = @config.endpoint.nil? ||
148
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
149
+ !@config.endpoint.split(".").first.include?("-"))
150
+ credentials ||= Credentials.default scope: @config.scope,
151
+ enable_self_signed_jwt: enable_self_signed_jwt
152
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
153
+ credentials = Credentials.new credentials, scope: @config.scope
154
+ end
155
+ @quota_project_id = @config.quota_project
156
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
157
+
158
+ @session_service_stub = ::Gapic::ServiceStub.new(
159
+ ::Google::Cloud::DiscoveryEngine::V1::SessionService::Stub,
160
+ credentials: credentials,
161
+ endpoint: @config.endpoint,
162
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
163
+ universe_domain: @config.universe_domain,
164
+ channel_args: @config.channel_args,
165
+ interceptors: @config.interceptors,
166
+ channel_pool_config: @config.channel_pool,
167
+ logger: @config.logger
168
+ )
169
+
170
+ @session_service_stub.stub_logger&.info do |entry|
171
+ entry.set_system_name
172
+ entry.set_service
173
+ entry.message = "Created client for #{entry.service}"
174
+ entry.set_credentials_fields credentials
175
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
176
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
177
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
178
+ end
179
+
180
+ @location_client = Google::Cloud::Location::Locations::Client.new do |config|
181
+ config.credentials = credentials
182
+ config.quota_project = @quota_project_id
183
+ config.endpoint = @session_service_stub.endpoint
184
+ config.universe_domain = @session_service_stub.universe_domain
185
+ config.logger = @session_service_stub.logger if config.respond_to? :logger=
186
+ end
187
+ end
188
+
189
+ ##
190
+ # Get the associated client for mix-in of the Locations.
191
+ #
192
+ # @return [Google::Cloud::Location::Locations::Client]
193
+ #
194
+ attr_reader :location_client
195
+
196
+ ##
197
+ # The logger used for request/response debug logging.
198
+ #
199
+ # @return [Logger]
200
+ #
201
+ def logger
202
+ @session_service_stub.logger
203
+ end
204
+
205
+ # Service calls
206
+
207
+ ##
208
+ # Creates a Session.
209
+ #
210
+ # If the {::Google::Cloud::DiscoveryEngine::V1::Session Session} to create already
211
+ # exists, an ALREADY_EXISTS error is returned.
212
+ #
213
+ # @overload create_session(request, options = nil)
214
+ # Pass arguments to `create_session` via a request object, either of type
215
+ # {::Google::Cloud::DiscoveryEngine::V1::CreateSessionRequest} or an equivalent Hash.
216
+ #
217
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::CreateSessionRequest, ::Hash]
218
+ # A request object representing the call parameters. Required. To specify no
219
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
220
+ # @param options [::Gapic::CallOptions, ::Hash]
221
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
222
+ #
223
+ # @overload create_session(parent: nil, session: nil)
224
+ # Pass arguments to `create_session` via keyword arguments. Note that at
225
+ # least one keyword argument is required. To specify no parameters, or to keep all
226
+ # the default parameter values, pass an empty Hash as a request object (see above).
227
+ #
228
+ # @param parent [::String]
229
+ # Required. Full resource name of parent data store. Format:
230
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store_id}`
231
+ # @param session [::Google::Cloud::DiscoveryEngine::V1::Session, ::Hash]
232
+ # Required. The session to create.
233
+ #
234
+ # @yield [response, operation] Access the result along with the RPC operation
235
+ # @yieldparam response [::Google::Cloud::DiscoveryEngine::V1::Session]
236
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
237
+ #
238
+ # @return [::Google::Cloud::DiscoveryEngine::V1::Session]
239
+ #
240
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
241
+ #
242
+ # @example Basic example
243
+ # require "google/cloud/discovery_engine/v1"
244
+ #
245
+ # # Create a client object. The client can be reused for multiple calls.
246
+ # client = Google::Cloud::DiscoveryEngine::V1::SessionService::Client.new
247
+ #
248
+ # # Create a request. To set request fields, pass in keyword arguments.
249
+ # request = Google::Cloud::DiscoveryEngine::V1::CreateSessionRequest.new
250
+ #
251
+ # # Call the create_session method.
252
+ # result = client.create_session request
253
+ #
254
+ # # The returned object is of type Google::Cloud::DiscoveryEngine::V1::Session.
255
+ # p result
256
+ #
257
+ def create_session request, options = nil
258
+ raise ::ArgumentError, "request must be provided" if request.nil?
259
+
260
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::CreateSessionRequest
261
+
262
+ # Converts hash and nil to an options object
263
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
264
+
265
+ # Customize the options with defaults
266
+ metadata = @config.rpcs.create_session.metadata.to_h
267
+
268
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
269
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
270
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
271
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
272
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
273
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
274
+
275
+ header_params = {}
276
+ if request.parent
277
+ header_params["parent"] = request.parent
278
+ end
279
+
280
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
281
+ metadata[:"x-goog-request-params"] ||= request_params_header
282
+
283
+ options.apply_defaults timeout: @config.rpcs.create_session.timeout,
284
+ metadata: metadata,
285
+ retry_policy: @config.rpcs.create_session.retry_policy
286
+
287
+ options.apply_defaults timeout: @config.timeout,
288
+ metadata: @config.metadata,
289
+ retry_policy: @config.retry_policy
290
+
291
+ @session_service_stub.call_rpc :create_session, request, options: options do |response, operation|
292
+ yield response, operation if block_given?
293
+ end
294
+ rescue ::GRPC::BadStatus => e
295
+ raise ::Google::Cloud::Error.from_error(e)
296
+ end
297
+
298
+ ##
299
+ # Deletes a Session.
300
+ #
301
+ # If the {::Google::Cloud::DiscoveryEngine::V1::Session Session} to delete does
302
+ # not exist, a NOT_FOUND error is returned.
303
+ #
304
+ # @overload delete_session(request, options = nil)
305
+ # Pass arguments to `delete_session` via a request object, either of type
306
+ # {::Google::Cloud::DiscoveryEngine::V1::DeleteSessionRequest} or an equivalent Hash.
307
+ #
308
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::DeleteSessionRequest, ::Hash]
309
+ # A request object representing the call parameters. Required. To specify no
310
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
311
+ # @param options [::Gapic::CallOptions, ::Hash]
312
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
313
+ #
314
+ # @overload delete_session(name: nil)
315
+ # Pass arguments to `delete_session` via keyword arguments. Note that at
316
+ # least one keyword argument is required. To specify no parameters, or to keep all
317
+ # the default parameter values, pass an empty Hash as a request object (see above).
318
+ #
319
+ # @param name [::String]
320
+ # Required. The resource name of the Session to delete. Format:
321
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store_id}/sessions/{session_id}`
322
+ #
323
+ # @yield [response, operation] Access the result along with the RPC operation
324
+ # @yieldparam response [::Google::Protobuf::Empty]
325
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
326
+ #
327
+ # @return [::Google::Protobuf::Empty]
328
+ #
329
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
330
+ #
331
+ # @example Basic example
332
+ # require "google/cloud/discovery_engine/v1"
333
+ #
334
+ # # Create a client object. The client can be reused for multiple calls.
335
+ # client = Google::Cloud::DiscoveryEngine::V1::SessionService::Client.new
336
+ #
337
+ # # Create a request. To set request fields, pass in keyword arguments.
338
+ # request = Google::Cloud::DiscoveryEngine::V1::DeleteSessionRequest.new
339
+ #
340
+ # # Call the delete_session method.
341
+ # result = client.delete_session request
342
+ #
343
+ # # The returned object is of type Google::Protobuf::Empty.
344
+ # p result
345
+ #
346
+ def delete_session request, options = nil
347
+ raise ::ArgumentError, "request must be provided" if request.nil?
348
+
349
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::DeleteSessionRequest
350
+
351
+ # Converts hash and nil to an options object
352
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
353
+
354
+ # Customize the options with defaults
355
+ metadata = @config.rpcs.delete_session.metadata.to_h
356
+
357
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
358
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
359
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
360
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
361
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
362
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
363
+
364
+ header_params = {}
365
+ if request.name
366
+ header_params["name"] = request.name
367
+ end
368
+
369
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
370
+ metadata[:"x-goog-request-params"] ||= request_params_header
371
+
372
+ options.apply_defaults timeout: @config.rpcs.delete_session.timeout,
373
+ metadata: metadata,
374
+ retry_policy: @config.rpcs.delete_session.retry_policy
375
+
376
+ options.apply_defaults timeout: @config.timeout,
377
+ metadata: @config.metadata,
378
+ retry_policy: @config.retry_policy
379
+
380
+ @session_service_stub.call_rpc :delete_session, request, options: options do |response, operation|
381
+ yield response, operation if block_given?
382
+ end
383
+ rescue ::GRPC::BadStatus => e
384
+ raise ::Google::Cloud::Error.from_error(e)
385
+ end
386
+
387
+ ##
388
+ # Updates a Session.
389
+ #
390
+ # {::Google::Cloud::DiscoveryEngine::V1::Session Session} action type cannot be
391
+ # changed. If the {::Google::Cloud::DiscoveryEngine::V1::Session Session} to
392
+ # update does not exist, a NOT_FOUND error is returned.
393
+ #
394
+ # @overload update_session(request, options = nil)
395
+ # Pass arguments to `update_session` via a request object, either of type
396
+ # {::Google::Cloud::DiscoveryEngine::V1::UpdateSessionRequest} or an equivalent Hash.
397
+ #
398
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::UpdateSessionRequest, ::Hash]
399
+ # A request object representing the call parameters. Required. To specify no
400
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
401
+ # @param options [::Gapic::CallOptions, ::Hash]
402
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
403
+ #
404
+ # @overload update_session(session: nil, update_mask: nil)
405
+ # Pass arguments to `update_session` via keyword arguments. Note that at
406
+ # least one keyword argument is required. To specify no parameters, or to keep all
407
+ # the default parameter values, pass an empty Hash as a request object (see above).
408
+ #
409
+ # @param session [::Google::Cloud::DiscoveryEngine::V1::Session, ::Hash]
410
+ # Required. The Session to update.
411
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
412
+ # Indicates which fields in the provided
413
+ # {::Google::Cloud::DiscoveryEngine::V1::Session Session} to update. The following
414
+ # are NOT supported:
415
+ #
416
+ # * {::Google::Cloud::DiscoveryEngine::V1::Session#name Session.name}
417
+ #
418
+ # If not set or empty, all supported fields are updated.
419
+ #
420
+ # @yield [response, operation] Access the result along with the RPC operation
421
+ # @yieldparam response [::Google::Cloud::DiscoveryEngine::V1::Session]
422
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
423
+ #
424
+ # @return [::Google::Cloud::DiscoveryEngine::V1::Session]
425
+ #
426
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
427
+ #
428
+ # @example Basic example
429
+ # require "google/cloud/discovery_engine/v1"
430
+ #
431
+ # # Create a client object. The client can be reused for multiple calls.
432
+ # client = Google::Cloud::DiscoveryEngine::V1::SessionService::Client.new
433
+ #
434
+ # # Create a request. To set request fields, pass in keyword arguments.
435
+ # request = Google::Cloud::DiscoveryEngine::V1::UpdateSessionRequest.new
436
+ #
437
+ # # Call the update_session method.
438
+ # result = client.update_session request
439
+ #
440
+ # # The returned object is of type Google::Cloud::DiscoveryEngine::V1::Session.
441
+ # p result
442
+ #
443
+ def update_session request, options = nil
444
+ raise ::ArgumentError, "request must be provided" if request.nil?
445
+
446
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::UpdateSessionRequest
447
+
448
+ # Converts hash and nil to an options object
449
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
450
+
451
+ # Customize the options with defaults
452
+ metadata = @config.rpcs.update_session.metadata.to_h
453
+
454
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
455
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
456
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
457
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
458
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
459
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
460
+
461
+ header_params = {}
462
+ if request.session&.name
463
+ header_params["session.name"] = request.session.name
464
+ end
465
+
466
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
467
+ metadata[:"x-goog-request-params"] ||= request_params_header
468
+
469
+ options.apply_defaults timeout: @config.rpcs.update_session.timeout,
470
+ metadata: metadata,
471
+ retry_policy: @config.rpcs.update_session.retry_policy
472
+
473
+ options.apply_defaults timeout: @config.timeout,
474
+ metadata: @config.metadata,
475
+ retry_policy: @config.retry_policy
476
+
477
+ @session_service_stub.call_rpc :update_session, request, options: options do |response, operation|
478
+ yield response, operation if block_given?
479
+ end
480
+ rescue ::GRPC::BadStatus => e
481
+ raise ::Google::Cloud::Error.from_error(e)
482
+ end
483
+
484
+ ##
485
+ # Gets a Session.
486
+ #
487
+ # @overload get_session(request, options = nil)
488
+ # Pass arguments to `get_session` via a request object, either of type
489
+ # {::Google::Cloud::DiscoveryEngine::V1::GetSessionRequest} or an equivalent Hash.
490
+ #
491
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::GetSessionRequest, ::Hash]
492
+ # A request object representing the call parameters. Required. To specify no
493
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
494
+ # @param options [::Gapic::CallOptions, ::Hash]
495
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
496
+ #
497
+ # @overload get_session(name: nil, include_answer_details: nil)
498
+ # Pass arguments to `get_session` via keyword arguments. Note that at
499
+ # least one keyword argument is required. To specify no parameters, or to keep all
500
+ # the default parameter values, pass an empty Hash as a request object (see above).
501
+ #
502
+ # @param name [::String]
503
+ # Required. The resource name of the Session to get. Format:
504
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store_id}/sessions/{session_id}`
505
+ # @param include_answer_details [::Boolean]
506
+ # Optional. If set to true, the full session including all answer details
507
+ # will be returned.
508
+ #
509
+ # @yield [response, operation] Access the result along with the RPC operation
510
+ # @yieldparam response [::Google::Cloud::DiscoveryEngine::V1::Session]
511
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
512
+ #
513
+ # @return [::Google::Cloud::DiscoveryEngine::V1::Session]
514
+ #
515
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
516
+ #
517
+ # @example Basic example
518
+ # require "google/cloud/discovery_engine/v1"
519
+ #
520
+ # # Create a client object. The client can be reused for multiple calls.
521
+ # client = Google::Cloud::DiscoveryEngine::V1::SessionService::Client.new
522
+ #
523
+ # # Create a request. To set request fields, pass in keyword arguments.
524
+ # request = Google::Cloud::DiscoveryEngine::V1::GetSessionRequest.new
525
+ #
526
+ # # Call the get_session method.
527
+ # result = client.get_session request
528
+ #
529
+ # # The returned object is of type Google::Cloud::DiscoveryEngine::V1::Session.
530
+ # p result
531
+ #
532
+ def get_session request, options = nil
533
+ raise ::ArgumentError, "request must be provided" if request.nil?
534
+
535
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::GetSessionRequest
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
+ metadata = @config.rpcs.get_session.metadata.to_h
542
+
543
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
544
+ 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::DiscoveryEngine::V1::VERSION
547
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
548
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
549
+
550
+ header_params = {}
551
+ if request.name
552
+ header_params["name"] = request.name
553
+ end
554
+
555
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
556
+ metadata[:"x-goog-request-params"] ||= request_params_header
557
+
558
+ options.apply_defaults timeout: @config.rpcs.get_session.timeout,
559
+ metadata: metadata,
560
+ retry_policy: @config.rpcs.get_session.retry_policy
561
+
562
+ options.apply_defaults timeout: @config.timeout,
563
+ metadata: @config.metadata,
564
+ retry_policy: @config.retry_policy
565
+
566
+ @session_service_stub.call_rpc :get_session, request, options: options do |response, operation|
567
+ yield response, operation if block_given?
568
+ end
569
+ rescue ::GRPC::BadStatus => e
570
+ raise ::Google::Cloud::Error.from_error(e)
571
+ end
572
+
573
+ ##
574
+ # Lists all Sessions by their parent
575
+ # {::Google::Cloud::DiscoveryEngine::V1::DataStore DataStore}.
576
+ #
577
+ # @overload list_sessions(request, options = nil)
578
+ # Pass arguments to `list_sessions` via a request object, either of type
579
+ # {::Google::Cloud::DiscoveryEngine::V1::ListSessionsRequest} or an equivalent Hash.
580
+ #
581
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::ListSessionsRequest, ::Hash]
582
+ # A request object representing the call parameters. Required. To specify no
583
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
584
+ # @param options [::Gapic::CallOptions, ::Hash]
585
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
586
+ #
587
+ # @overload list_sessions(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil)
588
+ # Pass arguments to `list_sessions` via keyword arguments. Note that at
589
+ # least one keyword argument is required. To specify no parameters, or to keep all
590
+ # the default parameter values, pass an empty Hash as a request object (see above).
591
+ #
592
+ # @param parent [::String]
593
+ # Required. The data store resource name. Format:
594
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store_id}`
595
+ # @param page_size [::Integer]
596
+ # Maximum number of results to return. If unspecified, defaults
597
+ # to 50. Max allowed value is 1000.
598
+ # @param page_token [::String]
599
+ # A page token, received from a previous `ListSessions` call.
600
+ # Provide this to retrieve the subsequent page.
601
+ # @param filter [::String]
602
+ # A comma-separated list of fields to filter by, in EBNF grammar.
603
+ # The supported fields are:
604
+ # * `user_pseudo_id`
605
+ # * `state`
606
+ # * `display_name`
607
+ # * `starred`
608
+ # * `is_pinned`
609
+ # * `labels`
610
+ # * `create_time`
611
+ # * `update_time`
612
+ #
613
+ # Examples:
614
+ # "user_pseudo_id = some_id"
615
+ # "display_name = \"some_name\""
616
+ # "starred = true"
617
+ # "is_pinned=true AND (NOT labels:hidden)"
618
+ # "create_time > \"1970-01-01T12:00:00Z\""
619
+ # @param order_by [::String]
620
+ # A comma-separated list of fields to order by, sorted in ascending order.
621
+ # Use "desc" after a field name for descending.
622
+ # Supported fields:
623
+ #
624
+ # * `update_time`
625
+ # * `create_time`
626
+ # * `session_name`
627
+ # * `is_pinned`
628
+ #
629
+ # Example:
630
+ #
631
+ # * "update_time desc"
632
+ # * "create_time"
633
+ # * "is_pinned desc,update_time desc": list sessions by is_pinned first, then
634
+ # by update_time.
635
+ #
636
+ # @yield [response, operation] Access the result along with the RPC operation
637
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::DiscoveryEngine::V1::Session>]
638
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
639
+ #
640
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::DiscoveryEngine::V1::Session>]
641
+ #
642
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
643
+ #
644
+ # @example Basic example
645
+ # require "google/cloud/discovery_engine/v1"
646
+ #
647
+ # # Create a client object. The client can be reused for multiple calls.
648
+ # client = Google::Cloud::DiscoveryEngine::V1::SessionService::Client.new
649
+ #
650
+ # # Create a request. To set request fields, pass in keyword arguments.
651
+ # request = Google::Cloud::DiscoveryEngine::V1::ListSessionsRequest.new
652
+ #
653
+ # # Call the list_sessions method.
654
+ # result = client.list_sessions request
655
+ #
656
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
657
+ # # over elements, and API calls will be issued to fetch pages as needed.
658
+ # result.each do |item|
659
+ # # Each element is of type ::Google::Cloud::DiscoveryEngine::V1::Session.
660
+ # p item
661
+ # end
662
+ #
663
+ def list_sessions request, options = nil
664
+ raise ::ArgumentError, "request must be provided" if request.nil?
665
+
666
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::ListSessionsRequest
667
+
668
+ # Converts hash and nil to an options object
669
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
670
+
671
+ # Customize the options with defaults
672
+ metadata = @config.rpcs.list_sessions.metadata.to_h
673
+
674
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
675
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
676
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
677
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
678
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
679
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
680
+
681
+ header_params = {}
682
+ if request.parent
683
+ header_params["parent"] = request.parent
684
+ end
685
+
686
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
687
+ metadata[:"x-goog-request-params"] ||= request_params_header
688
+
689
+ options.apply_defaults timeout: @config.rpcs.list_sessions.timeout,
690
+ metadata: metadata,
691
+ retry_policy: @config.rpcs.list_sessions.retry_policy
692
+
693
+ options.apply_defaults timeout: @config.timeout,
694
+ metadata: @config.metadata,
695
+ retry_policy: @config.retry_policy
696
+
697
+ @session_service_stub.call_rpc :list_sessions, request, options: options do |response, operation|
698
+ response = ::Gapic::PagedEnumerable.new @session_service_stub, :list_sessions, request, response, operation, options
699
+ yield response, operation if block_given?
700
+ throw :response, response
701
+ end
702
+ rescue ::GRPC::BadStatus => e
703
+ raise ::Google::Cloud::Error.from_error(e)
704
+ end
705
+
706
+ ##
707
+ # Configuration class for the SessionService API.
708
+ #
709
+ # This class represents the configuration for SessionService,
710
+ # providing control over timeouts, retry behavior, logging, transport
711
+ # parameters, and other low-level controls. Certain parameters can also be
712
+ # applied individually to specific RPCs. See
713
+ # {::Google::Cloud::DiscoveryEngine::V1::SessionService::Client::Configuration::Rpcs}
714
+ # for a list of RPCs that can be configured independently.
715
+ #
716
+ # Configuration can be applied globally to all clients, or to a single client
717
+ # on construction.
718
+ #
719
+ # @example
720
+ #
721
+ # # Modify the global config, setting the timeout for
722
+ # # create_session to 20 seconds,
723
+ # # and all remaining timeouts to 10 seconds.
724
+ # ::Google::Cloud::DiscoveryEngine::V1::SessionService::Client.configure do |config|
725
+ # config.timeout = 10.0
726
+ # config.rpcs.create_session.timeout = 20.0
727
+ # end
728
+ #
729
+ # # Apply the above configuration only to a new client.
730
+ # client = ::Google::Cloud::DiscoveryEngine::V1::SessionService::Client.new do |config|
731
+ # config.timeout = 10.0
732
+ # config.rpcs.create_session.timeout = 20.0
733
+ # end
734
+ #
735
+ # @!attribute [rw] endpoint
736
+ # A custom service endpoint, as a hostname or hostname:port. The default is
737
+ # nil, indicating to use the default endpoint in the current universe domain.
738
+ # @return [::String,nil]
739
+ # @!attribute [rw] credentials
740
+ # Credentials to send with calls. You may provide any of the following types:
741
+ # * (`String`) The path to a service account key file in JSON format
742
+ # * (`Hash`) A service account key as a Hash
743
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
744
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
745
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
746
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
747
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
748
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
749
+ # * (`nil`) indicating no credentials
750
+ #
751
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
752
+ # external source for authentication to Google Cloud, you must validate it before
753
+ # providing it to a Google API client library. Providing an unvalidated credential
754
+ # configuration to Google APIs can compromise the security of your systems and data.
755
+ # For more information, refer to [Validate credential configurations from external
756
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
757
+ # @return [::Object]
758
+ # @!attribute [rw] scope
759
+ # The OAuth scopes
760
+ # @return [::Array<::String>]
761
+ # @!attribute [rw] lib_name
762
+ # The library name as recorded in instrumentation and logging
763
+ # @return [::String]
764
+ # @!attribute [rw] lib_version
765
+ # The library version as recorded in instrumentation and logging
766
+ # @return [::String]
767
+ # @!attribute [rw] channel_args
768
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
769
+ # `GRPC::Core::Channel` object is provided as the credential.
770
+ # @return [::Hash]
771
+ # @!attribute [rw] interceptors
772
+ # An array of interceptors that are run before calls are executed.
773
+ # @return [::Array<::GRPC::ClientInterceptor>]
774
+ # @!attribute [rw] timeout
775
+ # The call timeout in seconds.
776
+ # @return [::Numeric]
777
+ # @!attribute [rw] metadata
778
+ # Additional gRPC headers to be sent with the call.
779
+ # @return [::Hash{::Symbol=>::String}]
780
+ # @!attribute [rw] retry_policy
781
+ # The retry policy. The value is a hash with the following keys:
782
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
783
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
784
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
785
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
786
+ # trigger a retry.
787
+ # @return [::Hash]
788
+ # @!attribute [rw] quota_project
789
+ # A separate project against which to charge quota.
790
+ # @return [::String]
791
+ # @!attribute [rw] universe_domain
792
+ # The universe domain within which to make requests. This determines the
793
+ # default endpoint URL. The default value of nil uses the environment
794
+ # universe (usually the default "googleapis.com" universe).
795
+ # @return [::String,nil]
796
+ # @!attribute [rw] logger
797
+ # A custom logger to use for request/response debug logging, or the value
798
+ # `:default` (the default) to construct a default logger, or `nil` to
799
+ # explicitly disable logging.
800
+ # @return [::Logger,:default,nil]
801
+ #
802
+ class Configuration
803
+ extend ::Gapic::Config
804
+
805
+ # @private
806
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
807
+ DEFAULT_ENDPOINT = "discoveryengine.googleapis.com"
808
+
809
+ config_attr :endpoint, nil, ::String, nil
810
+ config_attr :credentials, nil do |value|
811
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Google::Auth::BaseClient, ::Signet::OAuth2::Client, nil]
812
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC::Core::Channel
813
+ allowed.any? { |klass| klass === value }
814
+ end
815
+ config_attr :scope, nil, ::String, ::Array, nil
816
+ config_attr :lib_name, nil, ::String, nil
817
+ config_attr :lib_version, nil, ::String, nil
818
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
819
+ config_attr :interceptors, nil, ::Array, nil
820
+ config_attr :timeout, nil, ::Numeric, nil
821
+ config_attr :metadata, nil, ::Hash, nil
822
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
823
+ config_attr :quota_project, nil, ::String, nil
824
+ config_attr :universe_domain, nil, ::String, nil
825
+ config_attr :logger, :default, ::Logger, nil, :default
826
+
827
+ # @private
828
+ def initialize parent_config = nil
829
+ @parent_config = parent_config unless parent_config.nil?
830
+
831
+ yield self if block_given?
832
+ end
833
+
834
+ ##
835
+ # Configurations for individual RPCs
836
+ # @return [Rpcs]
837
+ #
838
+ def rpcs
839
+ @rpcs ||= begin
840
+ parent_rpcs = nil
841
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
842
+ Rpcs.new parent_rpcs
843
+ end
844
+ end
845
+
846
+ ##
847
+ # Configuration for the channel pool
848
+ # @return [::Gapic::ServiceStub::ChannelPool::Configuration]
849
+ #
850
+ def channel_pool
851
+ @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new
852
+ end
853
+
854
+ ##
855
+ # Configuration RPC class for the SessionService API.
856
+ #
857
+ # Includes fields providing the configuration for each RPC in this service.
858
+ # Each configuration object is of type `Gapic::Config::Method` and includes
859
+ # the following configuration fields:
860
+ #
861
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
862
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
863
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
864
+ # include the following keys:
865
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
866
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
867
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
868
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
869
+ # trigger a retry.
870
+ #
871
+ class Rpcs
872
+ ##
873
+ # RPC-specific configuration for `create_session`
874
+ # @return [::Gapic::Config::Method]
875
+ #
876
+ attr_reader :create_session
877
+ ##
878
+ # RPC-specific configuration for `delete_session`
879
+ # @return [::Gapic::Config::Method]
880
+ #
881
+ attr_reader :delete_session
882
+ ##
883
+ # RPC-specific configuration for `update_session`
884
+ # @return [::Gapic::Config::Method]
885
+ #
886
+ attr_reader :update_session
887
+ ##
888
+ # RPC-specific configuration for `get_session`
889
+ # @return [::Gapic::Config::Method]
890
+ #
891
+ attr_reader :get_session
892
+ ##
893
+ # RPC-specific configuration for `list_sessions`
894
+ # @return [::Gapic::Config::Method]
895
+ #
896
+ attr_reader :list_sessions
897
+
898
+ # @private
899
+ def initialize parent_rpcs = nil
900
+ create_session_config = parent_rpcs.create_session if parent_rpcs.respond_to? :create_session
901
+ @create_session = ::Gapic::Config::Method.new create_session_config
902
+ delete_session_config = parent_rpcs.delete_session if parent_rpcs.respond_to? :delete_session
903
+ @delete_session = ::Gapic::Config::Method.new delete_session_config
904
+ update_session_config = parent_rpcs.update_session if parent_rpcs.respond_to? :update_session
905
+ @update_session = ::Gapic::Config::Method.new update_session_config
906
+ get_session_config = parent_rpcs.get_session if parent_rpcs.respond_to? :get_session
907
+ @get_session = ::Gapic::Config::Method.new get_session_config
908
+ list_sessions_config = parent_rpcs.list_sessions if parent_rpcs.respond_to? :list_sessions
909
+ @list_sessions = ::Gapic::Config::Method.new list_sessions_config
910
+
911
+ yield self if block_given?
912
+ end
913
+ end
914
+ end
915
+ end
916
+ end
917
+ end
918
+ end
919
+ end
920
+ end