google-cloud-retail-v2 0.12.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/google/cloud/retail/v2/catalog_service/client.rb +18 -6
  4. data/lib/google/cloud/retail/v2/catalog_service/rest/client.rb +1220 -0
  5. data/lib/google/cloud/retail/v2/catalog_service/rest/service_stub.rb +704 -0
  6. data/lib/google/cloud/retail/v2/catalog_service/rest.rb +52 -0
  7. data/lib/google/cloud/retail/v2/catalog_service.rb +6 -0
  8. data/lib/google/cloud/retail/v2/completion_service/client.rb +18 -4
  9. data/lib/google/cloud/retail/v2/completion_service/operations.rb +12 -14
  10. data/lib/google/cloud/retail/v2/completion_service/rest/client.rb +533 -0
  11. data/lib/google/cloud/retail/v2/completion_service/rest/operations.rb +828 -0
  12. data/lib/google/cloud/retail/v2/completion_service/rest/service_stub.rb +167 -0
  13. data/lib/google/cloud/retail/v2/completion_service/rest.rb +56 -0
  14. data/lib/google/cloud/retail/v2/completion_service.rb +6 -0
  15. data/lib/google/cloud/retail/v2/control_service/client.rb +18 -6
  16. data/lib/google/cloud/retail/v2/control_service/rest/client.rb +680 -0
  17. data/lib/google/cloud/retail/v2/control_service/rest/service_stub.rb +345 -0
  18. data/lib/google/cloud/retail/v2/control_service/rest.rb +52 -0
  19. data/lib/google/cloud/retail/v2/control_service.rb +6 -0
  20. data/lib/google/cloud/retail/v2/prediction_service/client.rb +14 -0
  21. data/lib/google/cloud/retail/v2/prediction_service/rest/client.rb +486 -0
  22. data/lib/google/cloud/retail/v2/prediction_service/rest/service_stub.rb +116 -0
  23. data/lib/google/cloud/retail/v2/prediction_service/rest.rb +52 -0
  24. data/lib/google/cloud/retail/v2/prediction_service.rb +6 -0
  25. data/lib/google/cloud/retail/v2/product_service/client.rb +42 -30
  26. data/lib/google/cloud/retail/v2/product_service/operations.rb +12 -14
  27. data/lib/google/cloud/retail/v2/product_service/rest/client.rb +1649 -0
  28. data/lib/google/cloud/retail/v2/product_service/rest/operations.rb +828 -0
  29. data/lib/google/cloud/retail/v2/product_service/rest/service_stub.rb +705 -0
  30. data/lib/google/cloud/retail/v2/product_service/rest.rb +54 -0
  31. data/lib/google/cloud/retail/v2/product_service.rb +6 -0
  32. data/lib/google/cloud/retail/v2/rest.rb +44 -0
  33. data/lib/google/cloud/retail/v2/search_service/client.rb +18 -6
  34. data/lib/google/cloud/retail/v2/search_service/rest/client.rb +598 -0
  35. data/lib/google/cloud/retail/v2/search_service/rest/service_stub.rb +116 -0
  36. data/lib/google/cloud/retail/v2/search_service/rest.rb +55 -0
  37. data/lib/google/cloud/retail/v2/search_service.rb +6 -0
  38. data/lib/google/cloud/retail/v2/serving_config_service/client.rb +18 -6
  39. data/lib/google/cloud/retail/v2/serving_config_service/rest/client.rb +825 -0
  40. data/lib/google/cloud/retail/v2/serving_config_service/rest/service_stub.rb +465 -0
  41. data/lib/google/cloud/retail/v2/serving_config_service/rest.rb +52 -0
  42. data/lib/google/cloud/retail/v2/serving_config_service.rb +6 -0
  43. data/lib/google/cloud/retail/v2/user_event_service/client.rb +26 -12
  44. data/lib/google/cloud/retail/v2/user_event_service/operations.rb +12 -14
  45. data/lib/google/cloud/retail/v2/user_event_service/rest/client.rb +755 -0
  46. data/lib/google/cloud/retail/v2/user_event_service/rest/operations.rb +828 -0
  47. data/lib/google/cloud/retail/v2/user_event_service/rest/service_stub.rb +347 -0
  48. data/lib/google/cloud/retail/v2/user_event_service/rest.rb +53 -0
  49. data/lib/google/cloud/retail/v2/user_event_service.rb +6 -0
  50. data/lib/google/cloud/retail/v2/version.rb +1 -1
  51. data/lib/google/cloud/retail/v2.rb +5 -0
  52. metadata +58 -8
@@ -0,0 +1,598 @@
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/retail/v2/search_service_pb"
21
+ require "google/cloud/retail/v2/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 SearchService
29
+ module Rest
30
+ ##
31
+ # REST client for the SearchService service.
32
+ #
33
+ # Service for search.
34
+ #
35
+ # This feature is only available for users who have Retail Search enabled.
36
+ # Enable Retail Search on Cloud Console before using this feature.
37
+ #
38
+ class Client
39
+ include Paths
40
+
41
+ # @private
42
+ attr_reader :search_service_stub
43
+
44
+ ##
45
+ # Configure the SearchService Client class.
46
+ #
47
+ # See {::Google::Cloud::Retail::V2::SearchService::Rest::Client::Configuration}
48
+ # for a description of the configuration fields.
49
+ #
50
+ # @example
51
+ #
52
+ # # Modify the configuration for all SearchService clients
53
+ # ::Google::Cloud::Retail::V2::SearchService::Rest::Client.configure do |config|
54
+ # config.timeout = 10.0
55
+ # end
56
+ #
57
+ # @yield [config] Configure the Client client.
58
+ # @yieldparam config [Client::Configuration]
59
+ #
60
+ # @return [Client::Configuration]
61
+ #
62
+ def self.configure
63
+ @configure ||= begin
64
+ namespace = ["Google", "Cloud", "Retail", "V2"]
65
+ parent_config = while namespace.any?
66
+ parent_name = namespace.join "::"
67
+ parent_const = const_get parent_name
68
+ break parent_const.configure if parent_const.respond_to? :configure
69
+ namespace.pop
70
+ end
71
+ default_config = Client::Configuration.new parent_config
72
+
73
+ default_config.timeout = 5.0
74
+ default_config.retry_policy = {
75
+ initial_delay: 0.1, max_delay: 5.0, multiplier: 1.3, retry_codes: [14, 4]
76
+ }
77
+
78
+ default_config
79
+ end
80
+ yield @configure if block_given?
81
+ @configure
82
+ end
83
+
84
+ ##
85
+ # Configure the SearchService Client instance.
86
+ #
87
+ # The configuration is set to the derived mode, meaning that values can be changed,
88
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
89
+ # should be made on {Client.configure}.
90
+ #
91
+ # See {::Google::Cloud::Retail::V2::SearchService::Rest::Client::Configuration}
92
+ # for a description of the configuration fields.
93
+ #
94
+ # @yield [config] Configure the Client client.
95
+ # @yieldparam config [Client::Configuration]
96
+ #
97
+ # @return [Client::Configuration]
98
+ #
99
+ def configure
100
+ yield @config if block_given?
101
+ @config
102
+ end
103
+
104
+ ##
105
+ # Create a new SearchService REST client object.
106
+ #
107
+ # @example
108
+ #
109
+ # # Create a client using the default configuration
110
+ # client = ::Google::Cloud::Retail::V2::SearchService::Rest::Client.new
111
+ #
112
+ # # Create a client using a custom configuration
113
+ # client = ::Google::Cloud::Retail::V2::SearchService::Rest::Client.new do |config|
114
+ # config.timeout = 10.0
115
+ # end
116
+ #
117
+ # @yield [config] Configure the SearchService client.
118
+ # @yieldparam config [Client::Configuration]
119
+ #
120
+ def initialize
121
+ # Create the configuration object
122
+ @config = Configuration.new Client.configure
123
+
124
+ # Yield the configuration if needed
125
+ yield @config if block_given?
126
+
127
+ # Create credentials
128
+ credentials = @config.credentials
129
+ # Use self-signed JWT if the endpoint is unchanged from default,
130
+ # but only if the default endpoint does not have a region prefix.
131
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
132
+ !@config.endpoint.split(".").first.include?("-")
133
+ credentials ||= Credentials.default scope: @config.scope,
134
+ enable_self_signed_jwt: enable_self_signed_jwt
135
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
136
+ credentials = Credentials.new credentials, scope: @config.scope
137
+ end
138
+
139
+ @quota_project_id = @config.quota_project
140
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
141
+
142
+ @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
143
+ config.credentials = credentials
144
+ config.quota_project = @quota_project_id
145
+ config.endpoint = @config.endpoint
146
+ end
147
+
148
+ @search_service_stub = ::Google::Cloud::Retail::V2::SearchService::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
149
+ end
150
+
151
+ ##
152
+ # Get the associated client for mix-in of the Locations.
153
+ #
154
+ # @return [Google::Cloud::Location::Locations::Rest::Client]
155
+ #
156
+ attr_reader :location_client
157
+
158
+ # Service calls
159
+
160
+ ##
161
+ # Performs a search.
162
+ #
163
+ # This feature is only available for users who have Retail Search enabled.
164
+ # Enable Retail Search on Cloud Console before using this feature.
165
+ #
166
+ # @overload search(request, options = nil)
167
+ # Pass arguments to `search` via a request object, either of type
168
+ # {::Google::Cloud::Retail::V2::SearchRequest} or an equivalent Hash.
169
+ #
170
+ # @param request [::Google::Cloud::Retail::V2::SearchRequest, ::Hash]
171
+ # A request object representing the call parameters. Required. To specify no
172
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
173
+ # @param options [::Gapic::CallOptions, ::Hash]
174
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
175
+ #
176
+ # @overload search(placement: nil, branch: nil, query: nil, visitor_id: nil, user_info: nil, page_size: nil, page_token: nil, offset: nil, filter: nil, canonical_filter: nil, order_by: nil, facet_specs: nil, dynamic_facet_spec: nil, boost_spec: nil, query_expansion_spec: nil, variant_rollup_keys: nil, page_categories: nil, search_mode: nil, personalization_spec: nil, labels: nil, spell_correction_spec: nil)
177
+ # Pass arguments to `search` via keyword arguments. Note that at
178
+ # least one keyword argument is required. To specify no parameters, or to keep all
179
+ # the default parameter values, pass an empty Hash as a request object (see above).
180
+ #
181
+ # @param placement [::String]
182
+ # Required. The resource name of the Retail Search serving config, such as
183
+ # `projects/*/locations/global/catalogs/default_catalog/servingConfigs/default_serving_config`
184
+ # or the name of the legacy placement resource, such as
185
+ # `projects/*/locations/global/catalogs/default_catalog/placements/default_search`.
186
+ # This field is used to identify the serving config name and the set
187
+ # of models that will be used to make the search.
188
+ # @param branch [::String]
189
+ # The branch resource name, such as
190
+ # `projects/*/locations/global/catalogs/default_catalog/branches/0`.
191
+ #
192
+ # Use "default_branch" as the branch ID or leave this field empty, to search
193
+ # products under the default branch.
194
+ # @param query [::String]
195
+ # Raw search query.
196
+ #
197
+ # If this field is empty, the request is considered a category browsing
198
+ # request and returned results are based on
199
+ # {::Google::Cloud::Retail::V2::SearchRequest#filter filter} and
200
+ # {::Google::Cloud::Retail::V2::SearchRequest#page_categories page_categories}.
201
+ # @param visitor_id [::String]
202
+ # Required. A unique identifier for tracking visitors. For example, this
203
+ # could be implemented with an HTTP cookie, which should be able to uniquely
204
+ # identify a visitor on a single device. This unique identifier should not
205
+ # change if the visitor logs in or out of the website.
206
+ #
207
+ # This should be the same identifier as
208
+ # {::Google::Cloud::Retail::V2::UserEvent#visitor_id UserEvent.visitor_id}.
209
+ #
210
+ # The field must be a UTF-8 encoded string with a length limit of 128
211
+ # characters. Otherwise, an INVALID_ARGUMENT error is returned.
212
+ # @param user_info [::Google::Cloud::Retail::V2::UserInfo, ::Hash]
213
+ # User information.
214
+ # @param page_size [::Integer]
215
+ # Maximum number of {::Google::Cloud::Retail::V2::Product Product}s to return. If
216
+ # unspecified, defaults to a reasonable value. The maximum allowed value is
217
+ # 120. Values above 120 will be coerced to 120.
218
+ #
219
+ # If this field is negative, an INVALID_ARGUMENT is returned.
220
+ # @param page_token [::String]
221
+ # A page token
222
+ # {::Google::Cloud::Retail::V2::SearchResponse#next_page_token SearchResponse.next_page_token},
223
+ # received from a previous
224
+ # {::Google::Cloud::Retail::V2::SearchService::Rest::Client#search SearchService.Search} call.
225
+ # Provide this to retrieve the subsequent page.
226
+ #
227
+ # When paginating, all other parameters provided to
228
+ # {::Google::Cloud::Retail::V2::SearchService::Rest::Client#search SearchService.Search} must
229
+ # match the call that provided the page token. Otherwise, an INVALID_ARGUMENT
230
+ # error is returned.
231
+ # @param offset [::Integer]
232
+ # A 0-indexed integer that specifies the current offset (that is, starting
233
+ # result location, amongst the {::Google::Cloud::Retail::V2::Product Product}s
234
+ # deemed by the API as relevant) in search results. This field is only
235
+ # considered if {::Google::Cloud::Retail::V2::SearchRequest#page_token page_token}
236
+ # is unset.
237
+ #
238
+ # If this field is negative, an INVALID_ARGUMENT is returned.
239
+ # @param filter [::String]
240
+ # The filter syntax consists of an expression language for constructing a
241
+ # predicate from one or more fields of the products being filtered. Filter
242
+ # expression is case-sensitive. See more details at this [user
243
+ # guide](https://cloud.google.com/retail/docs/filter-and-order#filter).
244
+ #
245
+ # If this field is unrecognizable, an INVALID_ARGUMENT is returned.
246
+ # @param canonical_filter [::String]
247
+ # The default filter that is applied when a user performs a search without
248
+ # checking any filters on the search page.
249
+ #
250
+ # The filter applied to every search request when quality improvement such as
251
+ # query expansion is needed. For example, if a query does not have enough
252
+ # results, an expanded query with
253
+ # {::Google::Cloud::Retail::V2::SearchRequest#canonical_filter SearchRequest.canonical_filter}
254
+ # will be returned as a supplement of the original query. This field is
255
+ # strongly recommended to achieve high search quality.
256
+ #
257
+ # See {::Google::Cloud::Retail::V2::SearchRequest#filter SearchRequest.filter} for
258
+ # more details about filter syntax.
259
+ # @param order_by [::String]
260
+ # The order in which products are returned. Products can be ordered by
261
+ # a field in an {::Google::Cloud::Retail::V2::Product Product} object. Leave it
262
+ # unset if ordered by relevance. OrderBy expression is case-sensitive. See
263
+ # more details at this [user
264
+ # guide](https://cloud.google.com/retail/docs/filter-and-order#order).
265
+ #
266
+ # If this field is unrecognizable, an INVALID_ARGUMENT is returned.
267
+ # @param facet_specs [::Array<::Google::Cloud::Retail::V2::SearchRequest::FacetSpec, ::Hash>]
268
+ # Facet specifications for faceted search. If empty, no facets are returned.
269
+ #
270
+ # A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error
271
+ # is returned.
272
+ # @param dynamic_facet_spec [::Google::Cloud::Retail::V2::SearchRequest::DynamicFacetSpec, ::Hash]
273
+ # Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic
274
+ # to enable dynamic facets. Do not set this field.
275
+ #
276
+ # The specification for dynamically generated facets. Notice that only
277
+ # textual facets can be dynamically generated.
278
+ # @param boost_spec [::Google::Cloud::Retail::V2::SearchRequest::BoostSpec, ::Hash]
279
+ # Boost specification to boost certain products. See more details at this
280
+ # [user guide](https://cloud.google.com/retail/docs/boosting).
281
+ #
282
+ # Notice that if both
283
+ # {::Google::Cloud::Retail::V2::ServingConfig#boost_control_ids ServingConfig.boost_control_ids}
284
+ # and
285
+ # {::Google::Cloud::Retail::V2::SearchRequest#boost_spec SearchRequest.boost_spec}
286
+ # are set, the boost conditions from both places are evaluated. If a search
287
+ # request matches multiple boost conditions, the final boost score is equal
288
+ # to the sum of the boost scores from all matched boost conditions.
289
+ # @param query_expansion_spec [::Google::Cloud::Retail::V2::SearchRequest::QueryExpansionSpec, ::Hash]
290
+ # The query expansion specification that specifies the conditions under which
291
+ # query expansion will occur. See more details at this [user
292
+ # guide](https://cloud.google.com/retail/docs/result-size#query_expansion).
293
+ # @param variant_rollup_keys [::Array<::String>]
294
+ # The keys to fetch and rollup the matching
295
+ # {::Google::Cloud::Retail::V2::Product::Type::VARIANT variant}
296
+ # {::Google::Cloud::Retail::V2::Product Product}s attributes,
297
+ # {::Google::Cloud::Retail::V2::FulfillmentInfo FulfillmentInfo} or
298
+ # {::Google::Cloud::Retail::V2::LocalInventory LocalInventory}s attributes. The
299
+ # attributes from all the matching
300
+ # {::Google::Cloud::Retail::V2::Product::Type::VARIANT variant}
301
+ # {::Google::Cloud::Retail::V2::Product Product}s or
302
+ # {::Google::Cloud::Retail::V2::LocalInventory LocalInventory}s are merged and
303
+ # de-duplicated. Notice that rollup attributes will lead to extra query
304
+ # latency. Maximum number of keys is 30.
305
+ #
306
+ # For {::Google::Cloud::Retail::V2::FulfillmentInfo FulfillmentInfo}, a
307
+ # fulfillment type and a fulfillment ID must be provided in the format of
308
+ # "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123",
309
+ # "pickupInStore" is fulfillment type and "store123" is the store ID.
310
+ #
311
+ # Supported keys are:
312
+ #
313
+ # * colorFamilies
314
+ # * price
315
+ # * originalPrice
316
+ # * discount
317
+ # * variantId
318
+ # * inventory(place_id,price)
319
+ # * inventory(place_id,original_price)
320
+ # * inventory(place_id,attributes.key), where key is any key in the
321
+ # {::Google::Cloud::Retail::V2::LocalInventory#attributes Product.local_inventories.attributes}
322
+ # map.
323
+ # * attributes.key, where key is any key in the
324
+ # {::Google::Cloud::Retail::V2::Product#attributes Product.attributes} map.
325
+ # * pickupInStore.id, where id is any
326
+ # {::Google::Cloud::Retail::V2::FulfillmentInfo#place_ids FulfillmentInfo.place_ids}
327
+ # for {::Google::Cloud::Retail::V2::FulfillmentInfo#type FulfillmentInfo.type}
328
+ # "pickup-in-store".
329
+ # * shipToStore.id, where id is any
330
+ # {::Google::Cloud::Retail::V2::FulfillmentInfo#place_ids FulfillmentInfo.place_ids}
331
+ # for {::Google::Cloud::Retail::V2::FulfillmentInfo#type FulfillmentInfo.type}
332
+ # "ship-to-store".
333
+ # * sameDayDelivery.id, where id is any
334
+ # {::Google::Cloud::Retail::V2::FulfillmentInfo#place_ids FulfillmentInfo.place_ids}
335
+ # for {::Google::Cloud::Retail::V2::FulfillmentInfo#type FulfillmentInfo.type}
336
+ # "same-day-delivery".
337
+ # * nextDayDelivery.id, where id is any
338
+ # {::Google::Cloud::Retail::V2::FulfillmentInfo#place_ids FulfillmentInfo.place_ids}
339
+ # for {::Google::Cloud::Retail::V2::FulfillmentInfo#type FulfillmentInfo.type}
340
+ # "next-day-delivery".
341
+ # * customFulfillment1.id, where id is any
342
+ # {::Google::Cloud::Retail::V2::FulfillmentInfo#place_ids FulfillmentInfo.place_ids}
343
+ # for {::Google::Cloud::Retail::V2::FulfillmentInfo#type FulfillmentInfo.type}
344
+ # "custom-type-1".
345
+ # * customFulfillment2.id, where id is any
346
+ # {::Google::Cloud::Retail::V2::FulfillmentInfo#place_ids FulfillmentInfo.place_ids}
347
+ # for {::Google::Cloud::Retail::V2::FulfillmentInfo#type FulfillmentInfo.type}
348
+ # "custom-type-2".
349
+ # * customFulfillment3.id, where id is any
350
+ # {::Google::Cloud::Retail::V2::FulfillmentInfo#place_ids FulfillmentInfo.place_ids}
351
+ # for {::Google::Cloud::Retail::V2::FulfillmentInfo#type FulfillmentInfo.type}
352
+ # "custom-type-3".
353
+ # * customFulfillment4.id, where id is any
354
+ # {::Google::Cloud::Retail::V2::FulfillmentInfo#place_ids FulfillmentInfo.place_ids}
355
+ # for {::Google::Cloud::Retail::V2::FulfillmentInfo#type FulfillmentInfo.type}
356
+ # "custom-type-4".
357
+ # * customFulfillment5.id, where id is any
358
+ # {::Google::Cloud::Retail::V2::FulfillmentInfo#place_ids FulfillmentInfo.place_ids}
359
+ # for {::Google::Cloud::Retail::V2::FulfillmentInfo#type FulfillmentInfo.type}
360
+ # "custom-type-5".
361
+ #
362
+ # If this field is set to an invalid value other than these, an
363
+ # INVALID_ARGUMENT error is returned.
364
+ # @param page_categories [::Array<::String>]
365
+ # The categories associated with a category page. Required for category
366
+ # navigation queries to achieve good search quality. The format should be
367
+ # the same as
368
+ # {::Google::Cloud::Retail::V2::UserEvent#page_categories UserEvent.page_categories};
369
+ #
370
+ # To represent full path of category, use '>' sign to separate different
371
+ # hierarchies. If '>' is part of the category name, replace it with
372
+ # other character(s).
373
+ #
374
+ # Category pages include special pages such as sales or promotions. For
375
+ # instance, a special sale page may have the category hierarchy:
376
+ # "pageCategories" : ["Sales > 2017 Black Friday Deals"].
377
+ # @param search_mode [::Google::Cloud::Retail::V2::SearchRequest::SearchMode]
378
+ # The search mode of the search request. If not specified, a single search
379
+ # request triggers both product search and faceted search.
380
+ # @param personalization_spec [::Google::Cloud::Retail::V2::SearchRequest::PersonalizationSpec, ::Hash]
381
+ # The specification for personalization.
382
+ #
383
+ # Notice that if both
384
+ # {::Google::Cloud::Retail::V2::ServingConfig#personalization_spec ServingConfig.personalization_spec}
385
+ # and
386
+ # {::Google::Cloud::Retail::V2::SearchRequest#personalization_spec SearchRequest.personalization_spec}
387
+ # are set.
388
+ # {::Google::Cloud::Retail::V2::SearchRequest#personalization_spec SearchRequest.personalization_spec}
389
+ # will override
390
+ # {::Google::Cloud::Retail::V2::ServingConfig#personalization_spec ServingConfig.personalization_spec}.
391
+ # @param labels [::Hash{::String => ::String}]
392
+ # The labels applied to a resource must meet the following requirements:
393
+ #
394
+ # * Each resource can have multiple labels, up to a maximum of 64.
395
+ # * Each label must be a key-value pair.
396
+ # * Keys have a minimum length of 1 character and a maximum length of 63
397
+ # characters and cannot be empty. Values can be empty and have a maximum
398
+ # length of 63 characters.
399
+ # * Keys and values can contain only lowercase letters, numeric characters,
400
+ # underscores, and dashes. All characters must use UTF-8 encoding, and
401
+ # international characters are allowed.
402
+ # * The key portion of a label must be unique. However, you can use the same
403
+ # key with multiple resources.
404
+ # * Keys must start with a lowercase letter or international character.
405
+ #
406
+ # See [Google Cloud
407
+ # Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements)
408
+ # for more details.
409
+ # @param spell_correction_spec [::Google::Cloud::Retail::V2::SearchRequest::SpellCorrectionSpec, ::Hash]
410
+ # The spell correction specification that specifies the mode under
411
+ # which spell correction will take effect.
412
+ # @yield [result, operation] Access the result along with the TransportOperation object
413
+ # @yieldparam result [::Google::Cloud::Retail::V2::SearchResponse]
414
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
415
+ #
416
+ # @return [::Google::Cloud::Retail::V2::SearchResponse]
417
+ #
418
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
419
+ def search request, options = nil
420
+ raise ::ArgumentError, "request must be provided" if request.nil?
421
+
422
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::SearchRequest
423
+
424
+ # Converts hash and nil to an options object
425
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
426
+
427
+ # Customize the options with defaults
428
+ call_metadata = @config.rpcs.search.metadata.to_h
429
+
430
+ # Set x-goog-api-client and x-goog-user-project headers
431
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
432
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
433
+ gapic_version: ::Google::Cloud::Retail::V2::VERSION,
434
+ transports_version_send: [:rest]
435
+
436
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
437
+
438
+ options.apply_defaults timeout: @config.rpcs.search.timeout,
439
+ metadata: call_metadata,
440
+ retry_policy: @config.rpcs.search.retry_policy
441
+
442
+ options.apply_defaults timeout: @config.timeout,
443
+ metadata: @config.metadata,
444
+ retry_policy: @config.retry_policy
445
+
446
+ @search_service_stub.search request, options do |result, operation|
447
+ yield result, operation if block_given?
448
+ return result
449
+ end
450
+ rescue ::Gapic::Rest::Error => e
451
+ raise ::Google::Cloud::Error.from_error(e)
452
+ end
453
+
454
+ ##
455
+ # Configuration class for the SearchService REST API.
456
+ #
457
+ # This class represents the configuration for SearchService REST,
458
+ # providing control over timeouts, retry behavior, logging, transport
459
+ # parameters, and other low-level controls. Certain parameters can also be
460
+ # applied individually to specific RPCs. See
461
+ # {::Google::Cloud::Retail::V2::SearchService::Rest::Client::Configuration::Rpcs}
462
+ # for a list of RPCs that can be configured independently.
463
+ #
464
+ # Configuration can be applied globally to all clients, or to a single client
465
+ # on construction.
466
+ #
467
+ # @example
468
+ #
469
+ # # Modify the global config, setting the timeout for
470
+ # # search to 20 seconds,
471
+ # # and all remaining timeouts to 10 seconds.
472
+ # ::Google::Cloud::Retail::V2::SearchService::Rest::Client.configure do |config|
473
+ # config.timeout = 10.0
474
+ # config.rpcs.search.timeout = 20.0
475
+ # end
476
+ #
477
+ # # Apply the above configuration only to a new client.
478
+ # client = ::Google::Cloud::Retail::V2::SearchService::Rest::Client.new do |config|
479
+ # config.timeout = 10.0
480
+ # config.rpcs.search.timeout = 20.0
481
+ # end
482
+ #
483
+ # @!attribute [rw] endpoint
484
+ # The hostname or hostname:port of the service endpoint.
485
+ # Defaults to `"retail.googleapis.com"`.
486
+ # @return [::String]
487
+ # @!attribute [rw] credentials
488
+ # Credentials to send with calls. You may provide any of the following types:
489
+ # * (`String`) The path to a service account key file in JSON format
490
+ # * (`Hash`) A service account key as a Hash
491
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
492
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
493
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
494
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
495
+ # * (`nil`) indicating no credentials
496
+ # @return [::Object]
497
+ # @!attribute [rw] scope
498
+ # The OAuth scopes
499
+ # @return [::Array<::String>]
500
+ # @!attribute [rw] lib_name
501
+ # The library name as recorded in instrumentation and logging
502
+ # @return [::String]
503
+ # @!attribute [rw] lib_version
504
+ # The library version as recorded in instrumentation and logging
505
+ # @return [::String]
506
+ # @!attribute [rw] timeout
507
+ # The call timeout in seconds.
508
+ # @return [::Numeric]
509
+ # @!attribute [rw] metadata
510
+ # Additional headers to be sent with the call.
511
+ # @return [::Hash{::Symbol=>::String}]
512
+ # @!attribute [rw] retry_policy
513
+ # The retry policy. The value is a hash with the following keys:
514
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
515
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
516
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
517
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
518
+ # trigger a retry.
519
+ # @return [::Hash]
520
+ # @!attribute [rw] quota_project
521
+ # A separate project against which to charge quota.
522
+ # @return [::String]
523
+ #
524
+ class Configuration
525
+ extend ::Gapic::Config
526
+
527
+ config_attr :endpoint, "retail.googleapis.com", ::String
528
+ config_attr :credentials, nil do |value|
529
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
530
+ allowed.any? { |klass| klass === value }
531
+ end
532
+ config_attr :scope, nil, ::String, ::Array, nil
533
+ config_attr :lib_name, nil, ::String, nil
534
+ config_attr :lib_version, nil, ::String, nil
535
+ config_attr :timeout, nil, ::Numeric, nil
536
+ config_attr :metadata, nil, ::Hash, nil
537
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
538
+ config_attr :quota_project, nil, ::String, nil
539
+
540
+ # @private
541
+ def initialize parent_config = nil
542
+ @parent_config = parent_config unless parent_config.nil?
543
+
544
+ yield self if block_given?
545
+ end
546
+
547
+ ##
548
+ # Configurations for individual RPCs
549
+ # @return [Rpcs]
550
+ #
551
+ def rpcs
552
+ @rpcs ||= begin
553
+ parent_rpcs = nil
554
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
555
+ Rpcs.new parent_rpcs
556
+ end
557
+ end
558
+
559
+ ##
560
+ # Configuration RPC class for the SearchService API.
561
+ #
562
+ # Includes fields providing the configuration for each RPC in this service.
563
+ # Each configuration object is of type `Gapic::Config::Method` and includes
564
+ # the following configuration fields:
565
+ #
566
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
567
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
568
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
569
+ # include the following keys:
570
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
571
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
572
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
573
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
574
+ # trigger a retry.
575
+ #
576
+ class Rpcs
577
+ ##
578
+ # RPC-specific configuration for `search`
579
+ # @return [::Gapic::Config::Method]
580
+ #
581
+ attr_reader :search
582
+
583
+ # @private
584
+ def initialize parent_rpcs = nil
585
+ search_config = parent_rpcs.search if parent_rpcs.respond_to? :search
586
+ @search = ::Gapic::Config::Method.new search_config
587
+
588
+ yield self if block_given?
589
+ end
590
+ end
591
+ end
592
+ end
593
+ end
594
+ end
595
+ end
596
+ end
597
+ end
598
+ end