google-cloud-retail-v2 0.3.2 → 0.5.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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/lib/google/cloud/retail/v2/catalog_pb.rb +2 -0
  3. data/lib/google/cloud/retail/v2/catalog_service/client.rb +240 -40
  4. data/lib/google/cloud/retail/v2/catalog_service/paths.rb +21 -0
  5. data/lib/google/cloud/retail/v2/catalog_service_pb.rb +16 -0
  6. data/lib/google/cloud/retail/v2/catalog_service_services_pb.rb +46 -0
  7. data/lib/google/cloud/retail/v2/common_pb.rb +46 -0
  8. data/lib/google/cloud/retail/v2/completion_service/client.rb +545 -0
  9. data/lib/google/cloud/retail/v2/completion_service/credentials.rb +51 -0
  10. data/lib/google/cloud/retail/v2/completion_service/operations.rb +664 -0
  11. data/lib/google/cloud/retail/v2/completion_service/paths.rb +52 -0
  12. data/lib/google/cloud/retail/v2/completion_service.rb +54 -0
  13. data/lib/google/cloud/retail/v2/completion_service_pb.rb +50 -0
  14. data/lib/google/cloud/retail/v2/completion_service_services_pb.rb +61 -0
  15. data/lib/google/cloud/retail/v2/import_config_pb.rb +32 -0
  16. data/lib/google/cloud/retail/v2/prediction_service/client.rb +66 -70
  17. data/lib/google/cloud/retail/v2/product_pb.rb +21 -0
  18. data/lib/google/cloud/retail/v2/product_service/client.rb +682 -43
  19. data/lib/google/cloud/retail/v2/product_service/operations.rb +30 -21
  20. data/lib/google/cloud/retail/v2/product_service_pb.rb +56 -0
  21. data/lib/google/cloud/retail/v2/product_service_services_pb.rb +75 -0
  22. data/lib/google/cloud/retail/v2/search_service/client.rb +552 -0
  23. data/lib/google/cloud/retail/v2/search_service/credentials.rb +51 -0
  24. data/lib/google/cloud/retail/v2/search_service/paths.rb +54 -0
  25. data/lib/google/cloud/retail/v2/search_service.rb +53 -0
  26. data/lib/google/cloud/retail/v2/search_service_pb.rb +133 -0
  27. data/lib/google/cloud/retail/v2/search_service_services_pb.rb +53 -0
  28. data/lib/google/cloud/retail/v2/user_event_pb.rb +11 -0
  29. data/lib/google/cloud/retail/v2/user_event_service/client.rb +45 -42
  30. data/lib/google/cloud/retail/v2/user_event_service/operations.rb +30 -21
  31. data/lib/google/cloud/retail/v2/user_event_service/paths.rb +19 -0
  32. data/lib/google/cloud/retail/v2/version.rb +1 -1
  33. data/lib/google/cloud/retail/v2.rb +2 -0
  34. data/proto_docs/google/cloud/retail/v2/catalog.rb +6 -6
  35. data/proto_docs/google/cloud/retail/v2/catalog_service.rb +53 -4
  36. data/proto_docs/google/cloud/retail/v2/common.rb +272 -4
  37. data/proto_docs/google/cloud/retail/v2/completion_service.rb +164 -0
  38. data/proto_docs/google/cloud/retail/v2/import_config.rb +122 -6
  39. data/proto_docs/google/cloud/retail/v2/prediction_service.rb +32 -31
  40. data/proto_docs/google/cloud/retail/v2/product.rb +265 -9
  41. data/proto_docs/google/cloud/retail/v2/product_service.rb +362 -2
  42. data/proto_docs/google/cloud/retail/v2/purge_config.rb +1 -1
  43. data/proto_docs/google/cloud/retail/v2/search_service.rb +711 -0
  44. data/proto_docs/google/cloud/retail/v2/user_event.rb +110 -6
  45. data/proto_docs/google/type/date.rb +53 -0
  46. metadata +20 -4
@@ -8,20 +8,56 @@ require 'google/api/field_behavior_pb'
8
8
  require 'google/protobuf/timestamp_pb'
9
9
  Google::Protobuf::DescriptorPool.generated_pool.build do
10
10
  add_file("google/cloud/retail/v2/common.proto", :syntax => :proto3) do
11
+ add_message "google.cloud.retail.v2.Audience" do
12
+ repeated :genders, :string, 1
13
+ repeated :age_groups, :string, 2
14
+ end
15
+ add_message "google.cloud.retail.v2.ColorInfo" do
16
+ repeated :color_families, :string, 1
17
+ repeated :colors, :string, 2
18
+ end
11
19
  add_message "google.cloud.retail.v2.CustomAttribute" do
12
20
  repeated :text, :string, 1
13
21
  repeated :numbers, :double, 2
22
+ proto3_optional :searchable, :bool, 3
23
+ proto3_optional :indexable, :bool, 4
24
+ end
25
+ add_message "google.cloud.retail.v2.FulfillmentInfo" do
26
+ optional :type, :string, 1
27
+ repeated :place_ids, :string, 2
14
28
  end
15
29
  add_message "google.cloud.retail.v2.Image" do
16
30
  optional :uri, :string, 1
17
31
  optional :height, :int32, 2
18
32
  optional :width, :int32, 3
19
33
  end
34
+ add_message "google.cloud.retail.v2.Interval" do
35
+ oneof :min do
36
+ optional :minimum, :double, 1
37
+ optional :exclusive_minimum, :double, 2
38
+ end
39
+ oneof :max do
40
+ optional :maximum, :double, 3
41
+ optional :exclusive_maximum, :double, 4
42
+ end
43
+ end
20
44
  add_message "google.cloud.retail.v2.PriceInfo" do
21
45
  optional :currency_code, :string, 1
22
46
  optional :price, :float, 2
23
47
  optional :original_price, :float, 3
24
48
  optional :cost, :float, 4
49
+ optional :price_effective_time, :message, 5, "google.protobuf.Timestamp"
50
+ optional :price_expire_time, :message, 6, "google.protobuf.Timestamp"
51
+ optional :price_range, :message, 7, "google.cloud.retail.v2.PriceInfo.PriceRange"
52
+ end
53
+ add_message "google.cloud.retail.v2.PriceInfo.PriceRange" do
54
+ optional :price, :message, 1, "google.cloud.retail.v2.Interval"
55
+ optional :original_price, :message, 2, "google.cloud.retail.v2.Interval"
56
+ end
57
+ add_message "google.cloud.retail.v2.Rating" do
58
+ optional :rating_count, :int32, 1
59
+ optional :average_rating, :float, 2
60
+ repeated :rating_histogram, :int32, 3
25
61
  end
26
62
  add_message "google.cloud.retail.v2.UserInfo" do
27
63
  optional :user_id, :string, 1
@@ -29,6 +65,9 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
29
65
  optional :user_agent, :string, 3
30
66
  optional :direct_user_request, :bool, 4
31
67
  end
68
+ add_message "google.cloud.retail.v2.Promotion" do
69
+ optional :promotion_id, :string, 1
70
+ end
32
71
  end
33
72
  end
34
73
 
@@ -36,10 +75,17 @@ module Google
36
75
  module Cloud
37
76
  module Retail
38
77
  module V2
78
+ Audience = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.Audience").msgclass
79
+ ColorInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.ColorInfo").msgclass
39
80
  CustomAttribute = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.CustomAttribute").msgclass
81
+ FulfillmentInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.FulfillmentInfo").msgclass
40
82
  Image = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.Image").msgclass
83
+ Interval = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.Interval").msgclass
41
84
  PriceInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.PriceInfo").msgclass
85
+ PriceInfo::PriceRange = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.PriceInfo.PriceRange").msgclass
86
+ Rating = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.Rating").msgclass
42
87
  UserInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.UserInfo").msgclass
88
+ Promotion = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.retail.v2.Promotion").msgclass
43
89
  end
44
90
  end
45
91
  end
@@ -0,0 +1,545 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2021 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/completion_service_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Retail
25
+ module V2
26
+ module CompletionService
27
+ ##
28
+ # Client for the CompletionService service.
29
+ #
30
+ # Auto-completion service for retail.
31
+ #
32
+ # This feature is only available for users who have Retail Search enabled.
33
+ # Please submit a form [here](https://cloud.google.com/contact) to contact
34
+ # cloud sales if you are interested in using Retail Search.
35
+ #
36
+ class Client
37
+ include Paths
38
+
39
+ # @private
40
+ attr_reader :completion_service_stub
41
+
42
+ ##
43
+ # Configure the CompletionService Client class.
44
+ #
45
+ # See {::Google::Cloud::Retail::V2::CompletionService::Client::Configuration}
46
+ # for a description of the configuration fields.
47
+ #
48
+ # @example
49
+ #
50
+ # # Modify the configuration for all CompletionService clients
51
+ # ::Google::Cloud::Retail::V2::CompletionService::Client.configure do |config|
52
+ # config.timeout = 10.0
53
+ # end
54
+ #
55
+ # @yield [config] Configure the Client client.
56
+ # @yieldparam config [Client::Configuration]
57
+ #
58
+ # @return [Client::Configuration]
59
+ #
60
+ def self.configure
61
+ @configure ||= begin
62
+ namespace = ["Google", "Cloud", "Retail", "V2"]
63
+ parent_config = while namespace.any?
64
+ parent_name = namespace.join "::"
65
+ parent_const = const_get parent_name
66
+ break parent_const.configure if parent_const.respond_to? :configure
67
+ namespace.pop
68
+ end
69
+ default_config = Client::Configuration.new parent_config
70
+
71
+ default_config.timeout = 60.0
72
+ default_config.retry_policy = {
73
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
74
+ }
75
+
76
+ default_config
77
+ end
78
+ yield @configure if block_given?
79
+ @configure
80
+ end
81
+
82
+ ##
83
+ # Configure the CompletionService Client instance.
84
+ #
85
+ # The configuration is set to the derived mode, meaning that values can be changed,
86
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
87
+ # should be made on {Client.configure}.
88
+ #
89
+ # See {::Google::Cloud::Retail::V2::CompletionService::Client::Configuration}
90
+ # for a description of the configuration fields.
91
+ #
92
+ # @yield [config] Configure the Client client.
93
+ # @yieldparam config [Client::Configuration]
94
+ #
95
+ # @return [Client::Configuration]
96
+ #
97
+ def configure
98
+ yield @config if block_given?
99
+ @config
100
+ end
101
+
102
+ ##
103
+ # Create a new CompletionService client object.
104
+ #
105
+ # @example
106
+ #
107
+ # # Create a client using the default configuration
108
+ # client = ::Google::Cloud::Retail::V2::CompletionService::Client.new
109
+ #
110
+ # # Create a client using a custom configuration
111
+ # client = ::Google::Cloud::Retail::V2::CompletionService::Client.new do |config|
112
+ # config.timeout = 10.0
113
+ # end
114
+ #
115
+ # @yield [config] Configure the CompletionService client.
116
+ # @yieldparam config [Client::Configuration]
117
+ #
118
+ def initialize
119
+ # These require statements are intentionally placed here to initialize
120
+ # the gRPC module only when it's required.
121
+ # See https://github.com/googleapis/toolkit/issues/446
122
+ require "gapic/grpc"
123
+ require "google/cloud/retail/v2/completion_service_services_pb"
124
+
125
+ # Create the configuration object
126
+ @config = Configuration.new Client.configure
127
+
128
+ # Yield the configuration if needed
129
+ yield @config if block_given?
130
+
131
+ # Create credentials
132
+ credentials = @config.credentials
133
+ # Use self-signed JWT if the endpoint is unchanged from default,
134
+ # but only if the default endpoint does not have a region prefix.
135
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
136
+ !@config.endpoint.split(".").first.include?("-")
137
+ credentials ||= Credentials.default scope: @config.scope,
138
+ enable_self_signed_jwt: enable_self_signed_jwt
139
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
140
+ credentials = Credentials.new credentials, scope: @config.scope
141
+ end
142
+ @quota_project_id = @config.quota_project
143
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
144
+
145
+ @operations_client = Operations.new do |config|
146
+ config.credentials = credentials
147
+ config.endpoint = @config.endpoint
148
+ end
149
+
150
+ @completion_service_stub = ::Gapic::ServiceStub.new(
151
+ ::Google::Cloud::Retail::V2::CompletionService::Stub,
152
+ credentials: credentials,
153
+ endpoint: @config.endpoint,
154
+ channel_args: @config.channel_args,
155
+ interceptors: @config.interceptors
156
+ )
157
+ end
158
+
159
+ ##
160
+ # Get the associated client for long-running operations.
161
+ #
162
+ # @return [::Google::Cloud::Retail::V2::CompletionService::Operations]
163
+ #
164
+ attr_reader :operations_client
165
+
166
+ # Service calls
167
+
168
+ ##
169
+ # Completes the specified prefix with keyword suggestions.
170
+ #
171
+ # This feature is only available for users who have Retail Search enabled.
172
+ # Please submit a form [here](https://cloud.google.com/contact) to contact
173
+ # cloud sales if you are interested in using Retail Search.
174
+ #
175
+ # @overload complete_query(request, options = nil)
176
+ # Pass arguments to `complete_query` via a request object, either of type
177
+ # {::Google::Cloud::Retail::V2::CompleteQueryRequest} or an equivalent Hash.
178
+ #
179
+ # @param request [::Google::Cloud::Retail::V2::CompleteQueryRequest, ::Hash]
180
+ # A request object representing the call parameters. Required. To specify no
181
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
182
+ # @param options [::Gapic::CallOptions, ::Hash]
183
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
184
+ #
185
+ # @overload complete_query(catalog: nil, query: nil, visitor_id: nil, language_codes: nil, device_type: nil, dataset: nil, max_suggestions: nil)
186
+ # Pass arguments to `complete_query` via keyword arguments. Note that at
187
+ # least one keyword argument is required. To specify no parameters, or to keep all
188
+ # the default parameter values, pass an empty Hash as a request object (see above).
189
+ #
190
+ # @param catalog [::String]
191
+ # Required. Catalog for which the completion is performed.
192
+ #
193
+ # Full resource name of catalog, such as
194
+ # `projects/*/locations/global/catalogs/default_catalog`.
195
+ # @param query [::String]
196
+ # Required. The query used to generate suggestions.
197
+ #
198
+ # The maximum number of allowed characters is 255.
199
+ # @param visitor_id [::String]
200
+ # A unique identifier for tracking visitors. For example, this could be
201
+ # implemented with an HTTP cookie, which should be able to uniquely identify
202
+ # a visitor on a single device. This unique identifier should not change if
203
+ # the visitor logs in or out of the website.
204
+ #
205
+ # The field must be a UTF-8 encoded string with a length limit of 128
206
+ # characters. Otherwise, an INVALID_ARGUMENT error is returned.
207
+ # @param language_codes [::Array<::String>]
208
+ # The list of languages of the query. This is
209
+ # the BCP-47 language code, such as "en-US" or "sr-Latn".
210
+ # For more information, see
211
+ # [Tags for Identifying Languages](https://tools.ietf.org/html/bcp47).
212
+ #
213
+ # The maximum number of allowed characters is 255.
214
+ # Only "en-US" is currently supported.
215
+ # @param device_type [::String]
216
+ # The device type context for completion suggestions.
217
+ # It is useful to apply different suggestions on different device types, e.g.
218
+ # DESKTOP, MOBILE. If it is empty, the suggestions are across all device
219
+ # types.
220
+ #
221
+ # Supported formats:
222
+ #
223
+ # * UNKNOWN_DEVICE_TYPE
224
+ #
225
+ # * DESKTOP
226
+ #
227
+ # * MOBILE
228
+ #
229
+ # * A customized string starts with OTHER_, e.g. OTHER_IPHONE.
230
+ # @param dataset [::String]
231
+ # Determines which dataset to use for fetching completion. "user-data" will
232
+ # use the imported dataset through
233
+ # {::Google::Cloud::Retail::V2::CompletionService::Client#import_completion_data CompletionService.ImportCompletionData}.
234
+ # "cloud-retail" will use the dataset generated by cloud retail based on user
235
+ # events. If leave empty, it will use the "user-data".
236
+ #
237
+ # Current supported values:
238
+ #
239
+ # * user-data
240
+ #
241
+ # * cloud-retail
242
+ # This option requires additional allowlisting. Before using cloud-retail,
243
+ # contact Cloud Retail support team first.
244
+ # @param max_suggestions [::Integer]
245
+ # Completion max suggestions. If left unset or set to 0, then will fallback
246
+ # to the configured value [CompletionConfig.max_suggestions][].
247
+ #
248
+ # The maximum allowed max suggestions is 20. If it is set higher, it will be
249
+ # capped by 20.
250
+ #
251
+ # @yield [response, operation] Access the result along with the RPC operation
252
+ # @yieldparam response [::Google::Cloud::Retail::V2::CompleteQueryResponse]
253
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
254
+ #
255
+ # @return [::Google::Cloud::Retail::V2::CompleteQueryResponse]
256
+ #
257
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
258
+ #
259
+ def complete_query request, options = nil
260
+ raise ::ArgumentError, "request must be provided" if request.nil?
261
+
262
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::CompleteQueryRequest
263
+
264
+ # Converts hash and nil to an options object
265
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
266
+
267
+ # Customize the options with defaults
268
+ metadata = @config.rpcs.complete_query.metadata.to_h
269
+
270
+ # Set x-goog-api-client and x-goog-user-project headers
271
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
272
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
273
+ gapic_version: ::Google::Cloud::Retail::V2::VERSION
274
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
275
+
276
+ header_params = {
277
+ "catalog" => request.catalog
278
+ }
279
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
280
+ metadata[:"x-goog-request-params"] ||= request_params_header
281
+
282
+ options.apply_defaults timeout: @config.rpcs.complete_query.timeout,
283
+ metadata: metadata,
284
+ retry_policy: @config.rpcs.complete_query.retry_policy
285
+
286
+ options.apply_defaults timeout: @config.timeout,
287
+ metadata: @config.metadata,
288
+ retry_policy: @config.retry_policy
289
+
290
+ @completion_service_stub.call_rpc :complete_query, request, options: options do |response, operation|
291
+ yield response, operation if block_given?
292
+ return response
293
+ end
294
+ rescue ::GRPC::BadStatus => e
295
+ raise ::Google::Cloud::Error.from_error(e)
296
+ end
297
+
298
+ ##
299
+ # Bulk import of processed completion dataset.
300
+ #
301
+ # Request processing may be synchronous. Partial updating is not supported.
302
+ #
303
+ # This feature is only available for users who have Retail Search enabled.
304
+ # Please submit a form [here](https://cloud.google.com/contact) to contact
305
+ # cloud sales if you are interested in using Retail Search.
306
+ #
307
+ # @overload import_completion_data(request, options = nil)
308
+ # Pass arguments to `import_completion_data` via a request object, either of type
309
+ # {::Google::Cloud::Retail::V2::ImportCompletionDataRequest} or an equivalent Hash.
310
+ #
311
+ # @param request [::Google::Cloud::Retail::V2::ImportCompletionDataRequest, ::Hash]
312
+ # A request object representing the call parameters. Required. To specify no
313
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
314
+ # @param options [::Gapic::CallOptions, ::Hash]
315
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
316
+ #
317
+ # @overload import_completion_data(parent: nil, input_config: nil, notification_pubsub_topic: nil)
318
+ # Pass arguments to `import_completion_data` via keyword arguments. Note that at
319
+ # least one keyword argument is required. To specify no parameters, or to keep all
320
+ # the default parameter values, pass an empty Hash as a request object (see above).
321
+ #
322
+ # @param parent [::String]
323
+ # Required. The catalog which the suggestions dataset belongs to.
324
+ #
325
+ # Format: `projects/1234/locations/global/catalogs/default_catalog`.
326
+ # @param input_config [::Google::Cloud::Retail::V2::CompletionDataInputConfig, ::Hash]
327
+ # Required. The desired input location of the data.
328
+ # @param notification_pubsub_topic [::String]
329
+ # Pub/Sub topic for receiving notification. If this field is set,
330
+ # when the import is finished, a notification will be sent to
331
+ # specified Pub/Sub topic. The message data will be JSON string of a
332
+ # {::Google::Longrunning::Operation Operation}.
333
+ # Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`.
334
+ #
335
+ # @yield [response, operation] Access the result along with the RPC operation
336
+ # @yieldparam response [::Gapic::Operation]
337
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
338
+ #
339
+ # @return [::Gapic::Operation]
340
+ #
341
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
342
+ #
343
+ def import_completion_data request, options = nil
344
+ raise ::ArgumentError, "request must be provided" if request.nil?
345
+
346
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::ImportCompletionDataRequest
347
+
348
+ # Converts hash and nil to an options object
349
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
350
+
351
+ # Customize the options with defaults
352
+ metadata = @config.rpcs.import_completion_data.metadata.to_h
353
+
354
+ # Set x-goog-api-client and x-goog-user-project headers
355
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
356
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
357
+ gapic_version: ::Google::Cloud::Retail::V2::VERSION
358
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
359
+
360
+ header_params = {
361
+ "parent" => request.parent
362
+ }
363
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
364
+ metadata[:"x-goog-request-params"] ||= request_params_header
365
+
366
+ options.apply_defaults timeout: @config.rpcs.import_completion_data.timeout,
367
+ metadata: metadata,
368
+ retry_policy: @config.rpcs.import_completion_data.retry_policy
369
+
370
+ options.apply_defaults timeout: @config.timeout,
371
+ metadata: @config.metadata,
372
+ retry_policy: @config.retry_policy
373
+
374
+ @completion_service_stub.call_rpc :import_completion_data, request, options: options do |response, operation|
375
+ response = ::Gapic::Operation.new response, @operations_client, options: options
376
+ yield response, operation if block_given?
377
+ return response
378
+ end
379
+ rescue ::GRPC::BadStatus => e
380
+ raise ::Google::Cloud::Error.from_error(e)
381
+ end
382
+
383
+ ##
384
+ # Configuration class for the CompletionService API.
385
+ #
386
+ # This class represents the configuration for CompletionService,
387
+ # providing control over timeouts, retry behavior, logging, transport
388
+ # parameters, and other low-level controls. Certain parameters can also be
389
+ # applied individually to specific RPCs. See
390
+ # {::Google::Cloud::Retail::V2::CompletionService::Client::Configuration::Rpcs}
391
+ # for a list of RPCs that can be configured independently.
392
+ #
393
+ # Configuration can be applied globally to all clients, or to a single client
394
+ # on construction.
395
+ #
396
+ # @example
397
+ #
398
+ # # Modify the global config, setting the timeout for
399
+ # # complete_query to 20 seconds,
400
+ # # and all remaining timeouts to 10 seconds.
401
+ # ::Google::Cloud::Retail::V2::CompletionService::Client.configure do |config|
402
+ # config.timeout = 10.0
403
+ # config.rpcs.complete_query.timeout = 20.0
404
+ # end
405
+ #
406
+ # # Apply the above configuration only to a new client.
407
+ # client = ::Google::Cloud::Retail::V2::CompletionService::Client.new do |config|
408
+ # config.timeout = 10.0
409
+ # config.rpcs.complete_query.timeout = 20.0
410
+ # end
411
+ #
412
+ # @!attribute [rw] endpoint
413
+ # The hostname or hostname:port of the service endpoint.
414
+ # Defaults to `"retail.googleapis.com"`.
415
+ # @return [::String]
416
+ # @!attribute [rw] credentials
417
+ # Credentials to send with calls. You may provide any of the following types:
418
+ # * (`String`) The path to a service account key file in JSON format
419
+ # * (`Hash`) A service account key as a Hash
420
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
421
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
422
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
423
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
424
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
425
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
426
+ # * (`nil`) indicating no credentials
427
+ # @return [::Object]
428
+ # @!attribute [rw] scope
429
+ # The OAuth scopes
430
+ # @return [::Array<::String>]
431
+ # @!attribute [rw] lib_name
432
+ # The library name as recorded in instrumentation and logging
433
+ # @return [::String]
434
+ # @!attribute [rw] lib_version
435
+ # The library version as recorded in instrumentation and logging
436
+ # @return [::String]
437
+ # @!attribute [rw] channel_args
438
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
439
+ # `GRPC::Core::Channel` object is provided as the credential.
440
+ # @return [::Hash]
441
+ # @!attribute [rw] interceptors
442
+ # An array of interceptors that are run before calls are executed.
443
+ # @return [::Array<::GRPC::ClientInterceptor>]
444
+ # @!attribute [rw] timeout
445
+ # The call timeout in seconds.
446
+ # @return [::Numeric]
447
+ # @!attribute [rw] metadata
448
+ # Additional gRPC headers to be sent with the call.
449
+ # @return [::Hash{::Symbol=>::String}]
450
+ # @!attribute [rw] retry_policy
451
+ # The retry policy. The value is a hash with the following keys:
452
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
453
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
454
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
455
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
456
+ # trigger a retry.
457
+ # @return [::Hash]
458
+ # @!attribute [rw] quota_project
459
+ # A separate project against which to charge quota.
460
+ # @return [::String]
461
+ #
462
+ class Configuration
463
+ extend ::Gapic::Config
464
+
465
+ config_attr :endpoint, "retail.googleapis.com", ::String
466
+ config_attr :credentials, nil do |value|
467
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
468
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
469
+ allowed.any? { |klass| klass === value }
470
+ end
471
+ config_attr :scope, nil, ::String, ::Array, nil
472
+ config_attr :lib_name, nil, ::String, nil
473
+ config_attr :lib_version, nil, ::String, nil
474
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
475
+ config_attr :interceptors, nil, ::Array, nil
476
+ config_attr :timeout, nil, ::Numeric, nil
477
+ config_attr :metadata, nil, ::Hash, nil
478
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
479
+ config_attr :quota_project, nil, ::String, nil
480
+
481
+ # @private
482
+ def initialize parent_config = nil
483
+ @parent_config = parent_config unless parent_config.nil?
484
+
485
+ yield self if block_given?
486
+ end
487
+
488
+ ##
489
+ # Configurations for individual RPCs
490
+ # @return [Rpcs]
491
+ #
492
+ def rpcs
493
+ @rpcs ||= begin
494
+ parent_rpcs = nil
495
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
496
+ Rpcs.new parent_rpcs
497
+ end
498
+ end
499
+
500
+ ##
501
+ # Configuration RPC class for the CompletionService API.
502
+ #
503
+ # Includes fields providing the configuration for each RPC in this service.
504
+ # Each configuration object is of type `Gapic::Config::Method` and includes
505
+ # the following configuration fields:
506
+ #
507
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
508
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
509
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
510
+ # include the following keys:
511
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
512
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
513
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
514
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
515
+ # trigger a retry.
516
+ #
517
+ class Rpcs
518
+ ##
519
+ # RPC-specific configuration for `complete_query`
520
+ # @return [::Gapic::Config::Method]
521
+ #
522
+ attr_reader :complete_query
523
+ ##
524
+ # RPC-specific configuration for `import_completion_data`
525
+ # @return [::Gapic::Config::Method]
526
+ #
527
+ attr_reader :import_completion_data
528
+
529
+ # @private
530
+ def initialize parent_rpcs = nil
531
+ complete_query_config = parent_rpcs.complete_query if parent_rpcs.respond_to? :complete_query
532
+ @complete_query = ::Gapic::Config::Method.new complete_query_config
533
+ import_completion_data_config = parent_rpcs.import_completion_data if parent_rpcs.respond_to? :import_completion_data
534
+ @import_completion_data = ::Gapic::Config::Method.new import_completion_data_config
535
+
536
+ yield self if block_given?
537
+ end
538
+ end
539
+ end
540
+ end
541
+ end
542
+ end
543
+ end
544
+ end
545
+ end