google-cloud-retail-v2 2.3.0 → 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.
@@ -0,0 +1,526 @@
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/retail/v2/conversational_search_service_pb"
21
+ require "google/cloud/retail/v2/conversational_search_service/rest/service_stub"
22
+ require "google/cloud/location/rest"
23
+
24
+ module Google
25
+ module Cloud
26
+ module Retail
27
+ module V2
28
+ module ConversationalSearchService
29
+ module Rest
30
+ ##
31
+ # REST client for the ConversationalSearchService service.
32
+ #
33
+ # Service for retail conversational search.
34
+ #
35
+ # This feature is only available for users who have Retail Conversational
36
+ # Search enabled. Enable Retail Conversational Search on Cloud Console
37
+ # before using this feature.
38
+ #
39
+ class Client
40
+ # @private
41
+ API_VERSION = ""
42
+
43
+ # @private
44
+ DEFAULT_ENDPOINT_TEMPLATE = "retail.$UNIVERSE_DOMAIN$"
45
+
46
+ include Paths
47
+
48
+ # @private
49
+ attr_reader :conversational_search_service_stub
50
+
51
+ ##
52
+ # Configure the ConversationalSearchService Client class.
53
+ #
54
+ # See {::Google::Cloud::Retail::V2::ConversationalSearchService::Rest::Client::Configuration}
55
+ # for a description of the configuration fields.
56
+ #
57
+ # @example
58
+ #
59
+ # # Modify the configuration for all ConversationalSearchService clients
60
+ # ::Google::Cloud::Retail::V2::ConversationalSearchService::Rest::Client.configure do |config|
61
+ # config.timeout = 10.0
62
+ # end
63
+ #
64
+ # @yield [config] Configure the Client client.
65
+ # @yieldparam config [Client::Configuration]
66
+ #
67
+ # @return [Client::Configuration]
68
+ #
69
+ def self.configure
70
+ @configure ||= begin
71
+ namespace = ["Google", "Cloud", "Retail", "V2"]
72
+ parent_config = while namespace.any?
73
+ parent_name = namespace.join "::"
74
+ parent_const = const_get parent_name
75
+ break parent_const.configure if parent_const.respond_to? :configure
76
+ namespace.pop
77
+ end
78
+ default_config = Client::Configuration.new parent_config
79
+
80
+ default_config
81
+ end
82
+ yield @configure if block_given?
83
+ @configure
84
+ end
85
+
86
+ ##
87
+ # Configure the ConversationalSearchService Client instance.
88
+ #
89
+ # The configuration is set to the derived mode, meaning that values can be changed,
90
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
91
+ # should be made on {Client.configure}.
92
+ #
93
+ # See {::Google::Cloud::Retail::V2::ConversationalSearchService::Rest::Client::Configuration}
94
+ # for a description of the configuration fields.
95
+ #
96
+ # @yield [config] Configure the Client client.
97
+ # @yieldparam config [Client::Configuration]
98
+ #
99
+ # @return [Client::Configuration]
100
+ #
101
+ def configure
102
+ yield @config if block_given?
103
+ @config
104
+ end
105
+
106
+ ##
107
+ # The effective universe domain
108
+ #
109
+ # @return [String]
110
+ #
111
+ def universe_domain
112
+ @conversational_search_service_stub.universe_domain
113
+ end
114
+
115
+ ##
116
+ # Create a new ConversationalSearchService REST client object.
117
+ #
118
+ # @example
119
+ #
120
+ # # Create a client using the default configuration
121
+ # client = ::Google::Cloud::Retail::V2::ConversationalSearchService::Rest::Client.new
122
+ #
123
+ # # Create a client using a custom configuration
124
+ # client = ::Google::Cloud::Retail::V2::ConversationalSearchService::Rest::Client.new do |config|
125
+ # config.timeout = 10.0
126
+ # end
127
+ #
128
+ # @yield [config] Configure the ConversationalSearchService client.
129
+ # @yieldparam config [Client::Configuration]
130
+ #
131
+ def initialize
132
+ # Create the configuration object
133
+ @config = Configuration.new Client.configure
134
+
135
+ # Yield the configuration if needed
136
+ yield @config if block_given?
137
+
138
+ # Create credentials
139
+ credentials = @config.credentials
140
+ # Use self-signed JWT if the endpoint is unchanged from default,
141
+ # but only if the default endpoint does not have a region prefix.
142
+ enable_self_signed_jwt = @config.endpoint.nil? ||
143
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
144
+ !@config.endpoint.split(".").first.include?("-"))
145
+ credentials ||= Credentials.default scope: @config.scope,
146
+ enable_self_signed_jwt: enable_self_signed_jwt
147
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
148
+ credentials = Credentials.new credentials, scope: @config.scope
149
+ end
150
+
151
+ @quota_project_id = @config.quota_project
152
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
153
+
154
+ @conversational_search_service_stub = ::Google::Cloud::Retail::V2::ConversationalSearchService::Rest::ServiceStub.new(
155
+ endpoint: @config.endpoint,
156
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
157
+ universe_domain: @config.universe_domain,
158
+ credentials: credentials,
159
+ logger: @config.logger
160
+ )
161
+
162
+ @conversational_search_service_stub.logger(stub: true)&.info do |entry|
163
+ entry.set_system_name
164
+ entry.set_service
165
+ entry.message = "Created client for #{entry.service}"
166
+ entry.set_credentials_fields credentials
167
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
168
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
169
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
170
+ end
171
+
172
+ @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
173
+ config.credentials = credentials
174
+ config.quota_project = @quota_project_id
175
+ config.endpoint = @conversational_search_service_stub.endpoint
176
+ config.universe_domain = @conversational_search_service_stub.universe_domain
177
+ config.logger = @conversational_search_service_stub.logger if config.respond_to? :logger=
178
+ end
179
+ end
180
+
181
+ ##
182
+ # Get the associated client for mix-in of the Locations.
183
+ #
184
+ # @return [Google::Cloud::Location::Locations::Rest::Client]
185
+ #
186
+ attr_reader :location_client
187
+
188
+ ##
189
+ # The logger used for request/response debug logging.
190
+ #
191
+ # @return [Logger]
192
+ #
193
+ def logger
194
+ @conversational_search_service_stub.logger
195
+ end
196
+
197
+ # Service calls
198
+
199
+ ##
200
+ # Performs a conversational search.
201
+ #
202
+ # This feature is only available for users who have Conversational Search
203
+ # enabled.
204
+ #
205
+ # @overload conversational_search(request, options = nil)
206
+ # Pass arguments to `conversational_search` via a request object, either of type
207
+ # {::Google::Cloud::Retail::V2::ConversationalSearchRequest} or an equivalent Hash.
208
+ #
209
+ # @param request [::Google::Cloud::Retail::V2::ConversationalSearchRequest, ::Hash]
210
+ # A request object representing the call parameters. Required. To specify no
211
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
212
+ # @param options [::Gapic::CallOptions, ::Hash]
213
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
214
+ #
215
+ # @overload conversational_search(placement: nil, branch: nil, query: nil, page_categories: nil, conversation_id: nil, search_params: nil, visitor_id: nil, user_info: nil, conversational_filtering_spec: nil, user_labels: nil, safety_settings: nil)
216
+ # Pass arguments to `conversational_search` via keyword arguments. Note that at
217
+ # least one keyword argument is required. To specify no parameters, or to keep all
218
+ # the default parameter values, pass an empty Hash as a request object (see above).
219
+ #
220
+ # @param placement [::String]
221
+ # Required. The resource name of the search engine placement, such as
222
+ # `projects/*/locations/global/catalogs/default_catalog/placements/default_search`
223
+ # or
224
+ # `projects/*/locations/global/catalogs/default_catalog/servingConfigs/default_serving_config`
225
+ # This field is used to identify the serving config name and the set
226
+ # of models that will be used to make the search.
227
+ # @param branch [::String]
228
+ # Required. The branch resource name, such as
229
+ # `projects/*/locations/global/catalogs/default_catalog/branches/0`.
230
+ #
231
+ # Use "default_branch" as the branch ID or leave this field empty, to search
232
+ # products under the default branch.
233
+ # @param query [::String]
234
+ # Optional. Raw search query to be searched for.
235
+ #
236
+ # If this field is empty, the request is considered a category browsing
237
+ # request.
238
+ # @param page_categories [::Array<::String>]
239
+ # Optional. The categories associated with a category page. Must be set for
240
+ # category navigation queries to achieve good search quality. The format
241
+ # should be the same as
242
+ # {::Google::Cloud::Retail::V2::UserEvent#page_categories UserEvent.page_categories};
243
+ #
244
+ # To represent full path of category, use '>' sign to separate different
245
+ # hierarchies. If '>' is part of the category name, replace it with
246
+ # other character(s).
247
+ #
248
+ # Category pages include special pages such as sales or promotions. For
249
+ # instance, a special sale page may have the category hierarchy:
250
+ # "pageCategories" : ["Sales > 2017 Black Friday Deals"].
251
+ # @param conversation_id [::String]
252
+ # Optional. This field specifies the conversation id, which maintains the
253
+ # state of the conversation between client side and server side. Use the
254
+ # value from the previous
255
+ # {::Google::Cloud::Retail::V2::ConversationalSearchResponse#conversation_id ConversationalSearchResponse.conversation_id}.
256
+ # For the initial request, this should be empty.
257
+ # @param search_params [::Google::Cloud::Retail::V2::ConversationalSearchRequest::SearchParams, ::Hash]
258
+ # Optional. Search parameters.
259
+ # @param visitor_id [::String]
260
+ # Required. A unique identifier for tracking visitors. For example, this
261
+ # could be implemented with an HTTP cookie, which should be able to uniquely
262
+ # identify a visitor on a single device. This unique identifier should not
263
+ # change if the visitor logs in or out of the website.
264
+ #
265
+ # This should be the same identifier as
266
+ # {::Google::Cloud::Retail::V2::UserEvent#visitor_id UserEvent.visitor_id}.
267
+ #
268
+ # The field must be a UTF-8 encoded string with a length limit of 128
269
+ # characters. Otherwise, an INVALID_ARGUMENT error is returned.
270
+ # @param user_info [::Google::Cloud::Retail::V2::UserInfo, ::Hash]
271
+ # Optional. User information.
272
+ # @param conversational_filtering_spec [::Google::Cloud::Retail::V2::ConversationalSearchRequest::ConversationalFilteringSpec, ::Hash]
273
+ # Optional. This field specifies all conversational filtering related
274
+ # parameters.
275
+ # @param user_labels [::Hash{::String => ::String}]
276
+ # Optional. The user labels applied to a resource must meet the following
277
+ # requirements:
278
+ #
279
+ # * Each resource can have multiple labels, up to a maximum of 64.
280
+ # * Each label must be a key-value pair.
281
+ # * Keys have a minimum length of 1 character and a maximum length of 63
282
+ # characters and cannot be empty. Values can be empty and have a maximum
283
+ # length of 63 characters.
284
+ # * Keys and values can contain only lowercase letters, numeric characters,
285
+ # underscores, and dashes. All characters must use UTF-8 encoding, and
286
+ # international characters are allowed.
287
+ # * The key portion of a label must be unique. However, you can use the same
288
+ # key with multiple resources.
289
+ # * Keys must start with a lowercase letter or international character.
290
+ #
291
+ # See [Google Cloud
292
+ # Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements)
293
+ # for more details.
294
+ # @param safety_settings [::Array<::Google::Cloud::Retail::V2::SafetySetting, ::Hash>]
295
+ # Optional. The safety settings to be applied to the generated content.
296
+ # @return [::Enumerable<::Google::Cloud::Retail::V2::ConversationalSearchResponse>]
297
+ #
298
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
299
+ #
300
+ # @example Basic example
301
+ # require "google/cloud/retail/v2"
302
+ #
303
+ # # Create a client object. The client can be reused for multiple calls.
304
+ # client = Google::Cloud::Retail::V2::ConversationalSearchService::Rest::Client.new
305
+ #
306
+ # # Create a request. To set request fields, pass in keyword arguments.
307
+ # request = Google::Cloud::Retail::V2::ConversationalSearchRequest.new
308
+ #
309
+ # # Call the conversational_search method to start streaming.
310
+ # output = client.conversational_search request
311
+ #
312
+ # # The returned object is a streamed enumerable yielding elements of type
313
+ # # ::Google::Cloud::Retail::V2::ConversationalSearchResponse
314
+ # output.each do |current_response|
315
+ # p current_response
316
+ # end
317
+ #
318
+ def conversational_search request, options = nil
319
+ raise ::ArgumentError, "request must be provided" if request.nil?
320
+
321
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::ConversationalSearchRequest
322
+
323
+ # Converts hash and nil to an options object
324
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
325
+
326
+ # Customize the options with defaults
327
+ call_metadata = @config.rpcs.conversational_search.metadata.to_h
328
+
329
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
330
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
331
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
332
+ gapic_version: ::Google::Cloud::Retail::V2::VERSION,
333
+ transports_version_send: [:rest]
334
+
335
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
336
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
337
+
338
+ options.apply_defaults timeout: @config.rpcs.conversational_search.timeout,
339
+ metadata: call_metadata,
340
+ retry_policy: @config.rpcs.conversational_search.retry_policy
341
+
342
+ options.apply_defaults timeout: @config.timeout,
343
+ metadata: @config.metadata,
344
+ retry_policy: @config.retry_policy
345
+
346
+ ::Gapic::Rest::ServerStream.new(
347
+ ::Google::Cloud::Retail::V2::ConversationalSearchResponse,
348
+ ::Gapic::Rest::ThreadedEnumerator.new do |in_q, out_q|
349
+ @conversational_search_service_stub.conversational_search request, options do |chunk|
350
+ in_q.deq
351
+ out_q.enq chunk
352
+ end
353
+ end
354
+ )
355
+ rescue ::Gapic::Rest::Error => e
356
+ raise ::Google::Cloud::Error.from_error(e)
357
+ end
358
+
359
+ ##
360
+ # Configuration class for the ConversationalSearchService REST API.
361
+ #
362
+ # This class represents the configuration for ConversationalSearchService REST,
363
+ # providing control over timeouts, retry behavior, logging, transport
364
+ # parameters, and other low-level controls. Certain parameters can also be
365
+ # applied individually to specific RPCs. See
366
+ # {::Google::Cloud::Retail::V2::ConversationalSearchService::Rest::Client::Configuration::Rpcs}
367
+ # for a list of RPCs that can be configured independently.
368
+ #
369
+ # Configuration can be applied globally to all clients, or to a single client
370
+ # on construction.
371
+ #
372
+ # @example
373
+ #
374
+ # # Modify the global config, setting the timeout for
375
+ # # conversational_search to 20 seconds,
376
+ # # and all remaining timeouts to 10 seconds.
377
+ # ::Google::Cloud::Retail::V2::ConversationalSearchService::Rest::Client.configure do |config|
378
+ # config.timeout = 10.0
379
+ # config.rpcs.conversational_search.timeout = 20.0
380
+ # end
381
+ #
382
+ # # Apply the above configuration only to a new client.
383
+ # client = ::Google::Cloud::Retail::V2::ConversationalSearchService::Rest::Client.new do |config|
384
+ # config.timeout = 10.0
385
+ # config.rpcs.conversational_search.timeout = 20.0
386
+ # end
387
+ #
388
+ # @!attribute [rw] endpoint
389
+ # A custom service endpoint, as a hostname or hostname:port. The default is
390
+ # nil, indicating to use the default endpoint in the current universe domain.
391
+ # @return [::String,nil]
392
+ # @!attribute [rw] credentials
393
+ # Credentials to send with calls. You may provide any of the following types:
394
+ # * (`String`) The path to a service account key file in JSON format
395
+ # * (`Hash`) A service account key as a Hash
396
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
397
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
398
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
399
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
400
+ # * (`nil`) indicating no credentials
401
+ #
402
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
403
+ # external source for authentication to Google Cloud, you must validate it before
404
+ # providing it to a Google API client library. Providing an unvalidated credential
405
+ # configuration to Google APIs can compromise the security of your systems and data.
406
+ # For more information, refer to [Validate credential configurations from external
407
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
408
+ # @return [::Object]
409
+ # @!attribute [rw] scope
410
+ # The OAuth scopes
411
+ # @return [::Array<::String>]
412
+ # @!attribute [rw] lib_name
413
+ # The library name as recorded in instrumentation and logging
414
+ # @return [::String]
415
+ # @!attribute [rw] lib_version
416
+ # The library version as recorded in instrumentation and logging
417
+ # @return [::String]
418
+ # @!attribute [rw] timeout
419
+ # The call timeout in seconds.
420
+ # @return [::Numeric]
421
+ # @!attribute [rw] metadata
422
+ # Additional headers to be sent with the call.
423
+ # @return [::Hash{::Symbol=>::String}]
424
+ # @!attribute [rw] retry_policy
425
+ # The retry policy. The value is a hash with the following keys:
426
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
427
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
428
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
429
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
430
+ # trigger a retry.
431
+ # @return [::Hash]
432
+ # @!attribute [rw] quota_project
433
+ # A separate project against which to charge quota.
434
+ # @return [::String]
435
+ # @!attribute [rw] universe_domain
436
+ # The universe domain within which to make requests. This determines the
437
+ # default endpoint URL. The default value of nil uses the environment
438
+ # universe (usually the default "googleapis.com" universe).
439
+ # @return [::String,nil]
440
+ # @!attribute [rw] logger
441
+ # A custom logger to use for request/response debug logging, or the value
442
+ # `:default` (the default) to construct a default logger, or `nil` to
443
+ # explicitly disable logging.
444
+ # @return [::Logger,:default,nil]
445
+ #
446
+ class Configuration
447
+ extend ::Gapic::Config
448
+
449
+ # @private
450
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
451
+ DEFAULT_ENDPOINT = "retail.googleapis.com"
452
+
453
+ config_attr :endpoint, nil, ::String, nil
454
+ config_attr :credentials, nil do |value|
455
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Google::Auth::BaseClient, ::Signet::OAuth2::Client, nil]
456
+ allowed.any? { |klass| klass === value }
457
+ end
458
+ config_attr :scope, nil, ::String, ::Array, nil
459
+ config_attr :lib_name, nil, ::String, nil
460
+ config_attr :lib_version, nil, ::String, nil
461
+ config_attr :timeout, nil, ::Numeric, nil
462
+ config_attr :metadata, nil, ::Hash, nil
463
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
464
+ config_attr :quota_project, nil, ::String, nil
465
+ config_attr :universe_domain, nil, ::String, nil
466
+ config_attr :logger, :default, ::Logger, nil, :default
467
+
468
+ # @private
469
+ def initialize parent_config = nil
470
+ @parent_config = parent_config unless parent_config.nil?
471
+
472
+ yield self if block_given?
473
+ end
474
+
475
+ ##
476
+ # Configurations for individual RPCs
477
+ # @return [Rpcs]
478
+ #
479
+ def rpcs
480
+ @rpcs ||= begin
481
+ parent_rpcs = nil
482
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
483
+ Rpcs.new parent_rpcs
484
+ end
485
+ end
486
+
487
+ ##
488
+ # Configuration RPC class for the ConversationalSearchService API.
489
+ #
490
+ # Includes fields providing the configuration for each RPC in this service.
491
+ # Each configuration object is of type `Gapic::Config::Method` and includes
492
+ # the following configuration fields:
493
+ #
494
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
495
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
496
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
497
+ # include the following keys:
498
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
499
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
500
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
501
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
502
+ # trigger a retry.
503
+ #
504
+ class Rpcs
505
+ ##
506
+ # RPC-specific configuration for `conversational_search`
507
+ # @return [::Gapic::Config::Method]
508
+ #
509
+ attr_reader :conversational_search
510
+
511
+ # @private
512
+ def initialize parent_rpcs = nil
513
+ conversational_search_config = parent_rpcs.conversational_search if parent_rpcs.respond_to? :conversational_search
514
+ @conversational_search = ::Gapic::Config::Method.new conversational_search_config
515
+
516
+ yield self if block_given?
517
+ end
518
+ end
519
+ end
520
+ end
521
+ end
522
+ end
523
+ end
524
+ end
525
+ end
526
+ end
@@ -0,0 +1,145 @@
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/retail/v2/conversational_search_service_pb"
20
+
21
+ module Google
22
+ module Cloud
23
+ module Retail
24
+ module V2
25
+ module ConversationalSearchService
26
+ module Rest
27
+ ##
28
+ # REST service stub for the ConversationalSearchService service.
29
+ # Service stub contains baseline method implementations
30
+ # including transcoding, making the REST call, and deserialing the response.
31
+ #
32
+ class ServiceStub
33
+ # @private
34
+ def initialize endpoint:, endpoint_template:, universe_domain:, credentials:, logger:
35
+ # These require statements are intentionally placed here to initialize
36
+ # the REST modules only when it's required.
37
+ require "gapic/rest"
38
+
39
+ @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint,
40
+ endpoint_template: endpoint_template,
41
+ universe_domain: universe_domain,
42
+ credentials: credentials,
43
+ numeric_enums: true,
44
+ service_name: self.class,
45
+ raise_faraday_errors: false,
46
+ logger: logger
47
+ end
48
+
49
+ ##
50
+ # The effective universe domain
51
+ #
52
+ # @return [String]
53
+ #
54
+ def universe_domain
55
+ @client_stub.universe_domain
56
+ end
57
+
58
+ ##
59
+ # The effective endpoint
60
+ #
61
+ # @return [String]
62
+ #
63
+ def endpoint
64
+ @client_stub.endpoint
65
+ end
66
+
67
+ ##
68
+ # The logger used for request/response debug logging.
69
+ #
70
+ # @return [Logger]
71
+ #
72
+ def logger stub: false
73
+ stub ? @client_stub.stub_logger : @client_stub.logger
74
+ end
75
+
76
+ ##
77
+ # Baseline implementation for the conversational_search REST call
78
+ #
79
+ # @param request_pb [::Google::Cloud::Retail::V2::ConversationalSearchRequest]
80
+ # A request object representing the call parameters. Required.
81
+ # @param options [::Gapic::CallOptions]
82
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
83
+ #
84
+ # @yieldparam chunk [::String] The chunk of data received during server streaming.
85
+ #
86
+ # @return [::Gapic::Rest::TransportOperation]
87
+ def conversational_search(request_pb, options = nil, &)
88
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
89
+
90
+ verb, uri, query_string_params, body = ServiceStub.transcode_conversational_search_request request_pb
91
+ query_string_params = if query_string_params.any?
92
+ query_string_params.to_h { |p| p.split "=", 2 }
93
+ else
94
+ {}
95
+ end
96
+
97
+ response = @client_stub.make_http_request(
98
+ verb,
99
+ uri: uri,
100
+ body: body || "",
101
+ params: query_string_params,
102
+ method_name: "conversational_search",
103
+ options: options,
104
+ is_server_streaming: true,
105
+ &
106
+ )
107
+ ::Gapic::Rest::TransportOperation.new response
108
+ end
109
+
110
+ ##
111
+ # @private
112
+ #
113
+ # GRPC transcoding helper method for the conversational_search REST call
114
+ #
115
+ # @param request_pb [::Google::Cloud::Retail::V2::ConversationalSearchRequest]
116
+ # A request object representing the call parameters. Required.
117
+ # @return [Array(String, [String, nil], Hash{String => String})]
118
+ # Uri, Body, Query string parameters
119
+ def self.transcode_conversational_search_request request_pb
120
+ transcoder = Gapic::Rest::GrpcTranscoder.new
121
+ .with_bindings(
122
+ uri_method: :post,
123
+ uri_template: "/v2/{placement}:conversationalSearch",
124
+ body: "*",
125
+ matches: [
126
+ ["placement", %r{^projects/[^/]+/locations/[^/]+/catalogs/[^/]+/placements/[^/]+/?$}, false]
127
+ ]
128
+ )
129
+ .with_bindings(
130
+ uri_method: :post,
131
+ uri_template: "/v2/{placement}:conversationalSearch",
132
+ body: "*",
133
+ matches: [
134
+ ["placement", %r{^projects/[^/]+/locations/[^/]+/catalogs/[^/]+/servingConfigs/[^/]+/?$}, false]
135
+ ]
136
+ )
137
+ transcoder.transcode request_pb
138
+ end
139
+ end
140
+ end
141
+ end
142
+ end
143
+ end
144
+ end
145
+ end