google-cloud-retail-v2 0.13.0 → 0.14.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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/google/cloud/retail/v2/catalog_service/rest/client.rb +1220 -0
- data/lib/google/cloud/retail/v2/catalog_service/rest/service_stub.rb +704 -0
- data/lib/google/cloud/retail/v2/catalog_service/rest.rb +52 -0
- data/lib/google/cloud/retail/v2/catalog_service.rb +6 -0
- data/lib/google/cloud/retail/v2/completion_service/rest/client.rb +533 -0
- data/lib/google/cloud/retail/v2/completion_service/rest/operations.rb +828 -0
- data/lib/google/cloud/retail/v2/completion_service/rest/service_stub.rb +167 -0
- data/lib/google/cloud/retail/v2/completion_service/rest.rb +56 -0
- data/lib/google/cloud/retail/v2/completion_service.rb +6 -0
- data/lib/google/cloud/retail/v2/control_service/rest/client.rb +680 -0
- data/lib/google/cloud/retail/v2/control_service/rest/service_stub.rb +345 -0
- data/lib/google/cloud/retail/v2/control_service/rest.rb +52 -0
- data/lib/google/cloud/retail/v2/control_service.rb +6 -0
- data/lib/google/cloud/retail/v2/prediction_service/rest/client.rb +486 -0
- data/lib/google/cloud/retail/v2/prediction_service/rest/service_stub.rb +116 -0
- data/lib/google/cloud/retail/v2/prediction_service/rest.rb +52 -0
- data/lib/google/cloud/retail/v2/prediction_service.rb +6 -0
- data/lib/google/cloud/retail/v2/product_service/rest/client.rb +1649 -0
- data/lib/google/cloud/retail/v2/product_service/rest/operations.rb +828 -0
- data/lib/google/cloud/retail/v2/product_service/rest/service_stub.rb +705 -0
- data/lib/google/cloud/retail/v2/product_service/rest.rb +54 -0
- data/lib/google/cloud/retail/v2/product_service.rb +6 -0
- data/lib/google/cloud/retail/v2/rest.rb +44 -0
- data/lib/google/cloud/retail/v2/search_service/rest/client.rb +598 -0
- data/lib/google/cloud/retail/v2/search_service/rest/service_stub.rb +116 -0
- data/lib/google/cloud/retail/v2/search_service/rest.rb +55 -0
- data/lib/google/cloud/retail/v2/search_service.rb +6 -0
- data/lib/google/cloud/retail/v2/serving_config_service/rest/client.rb +825 -0
- data/lib/google/cloud/retail/v2/serving_config_service/rest/service_stub.rb +465 -0
- data/lib/google/cloud/retail/v2/serving_config_service/rest.rb +52 -0
- data/lib/google/cloud/retail/v2/serving_config_service.rb +6 -0
- data/lib/google/cloud/retail/v2/user_event_service/rest/client.rb +755 -0
- data/lib/google/cloud/retail/v2/user_event_service/rest/operations.rb +828 -0
- data/lib/google/cloud/retail/v2/user_event_service/rest/service_stub.rb +347 -0
- data/lib/google/cloud/retail/v2/user_event_service/rest.rb +53 -0
- data/lib/google/cloud/retail/v2/user_event_service.rb +6 -0
- data/lib/google/cloud/retail/v2/version.rb +1 -1
- data/lib/google/cloud/retail/v2.rb +5 -0
- metadata +35 -5
@@ -0,0 +1,52 @@
|
|
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 "gapic/rest"
|
20
|
+
require "gapic/config"
|
21
|
+
require "gapic/config/method"
|
22
|
+
|
23
|
+
require "google/cloud/retail/v2/version"
|
24
|
+
|
25
|
+
require "google/cloud/retail/v2/catalog_service/credentials"
|
26
|
+
require "google/cloud/retail/v2/catalog_service/paths"
|
27
|
+
require "google/cloud/retail/v2/catalog_service/rest/client"
|
28
|
+
|
29
|
+
module Google
|
30
|
+
module Cloud
|
31
|
+
module Retail
|
32
|
+
module V2
|
33
|
+
##
|
34
|
+
# Service for managing catalog configuration.
|
35
|
+
#
|
36
|
+
# To load this service and instantiate a REST client:
|
37
|
+
#
|
38
|
+
# require "google/cloud/retail/v2/catalog_service/rest"
|
39
|
+
# client = ::Google::Cloud::Retail::V2::CatalogService::Rest::Client.new
|
40
|
+
#
|
41
|
+
module CatalogService
|
42
|
+
# Client for the REST transport
|
43
|
+
module Rest
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
helper_path = ::File.join __dir__, "rest", "helpers.rb"
|
52
|
+
require "google/cloud/retail/v2/catalog_service/rest/helpers" if ::File.file? helper_path
|
@@ -25,6 +25,7 @@ require "google/cloud/retail/v2/version"
|
|
25
25
|
require "google/cloud/retail/v2/catalog_service/credentials"
|
26
26
|
require "google/cloud/retail/v2/catalog_service/paths"
|
27
27
|
require "google/cloud/retail/v2/catalog_service/client"
|
28
|
+
require "google/cloud/retail/v2/catalog_service/rest"
|
28
29
|
|
29
30
|
module Google
|
30
31
|
module Cloud
|
@@ -38,6 +39,11 @@ module Google
|
|
38
39
|
# require "google/cloud/retail/v2/catalog_service"
|
39
40
|
# client = ::Google::Cloud::Retail::V2::CatalogService::Client.new
|
40
41
|
#
|
42
|
+
# @example Load this service and instantiate a REST client
|
43
|
+
#
|
44
|
+
# require "google/cloud/retail/v2/catalog_service/rest"
|
45
|
+
# client = ::Google::Cloud::Retail::V2::CatalogService::Rest::Client.new
|
46
|
+
#
|
41
47
|
module CatalogService
|
42
48
|
end
|
43
49
|
end
|
@@ -0,0 +1,533 @@
|
|
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/completion_service_pb"
|
21
|
+
require "google/cloud/retail/v2/completion_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 CompletionService
|
29
|
+
module Rest
|
30
|
+
##
|
31
|
+
# REST client for the CompletionService service.
|
32
|
+
#
|
33
|
+
# Auto-completion service for retail.
|
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 :completion_service_stub
|
43
|
+
|
44
|
+
##
|
45
|
+
# Configure the CompletionService Client class.
|
46
|
+
#
|
47
|
+
# See {::Google::Cloud::Retail::V2::CompletionService::Rest::Client::Configuration}
|
48
|
+
# for a description of the configuration fields.
|
49
|
+
#
|
50
|
+
# @example
|
51
|
+
#
|
52
|
+
# # Modify the configuration for all CompletionService clients
|
53
|
+
# ::Google::Cloud::Retail::V2::CompletionService::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 CompletionService 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::CompletionService::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 CompletionService REST client object.
|
106
|
+
#
|
107
|
+
# @example
|
108
|
+
#
|
109
|
+
# # Create a client using the default configuration
|
110
|
+
# client = ::Google::Cloud::Retail::V2::CompletionService::Rest::Client.new
|
111
|
+
#
|
112
|
+
# # Create a client using a custom configuration
|
113
|
+
# client = ::Google::Cloud::Retail::V2::CompletionService::Rest::Client.new do |config|
|
114
|
+
# config.timeout = 10.0
|
115
|
+
# end
|
116
|
+
#
|
117
|
+
# @yield [config] Configure the CompletionService 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
|
+
@operations_client = ::Google::Cloud::Retail::V2::CompletionService::Rest::Operations.new do |config|
|
143
|
+
config.credentials = credentials
|
144
|
+
config.quota_project = @quota_project_id
|
145
|
+
config.endpoint = @config.endpoint
|
146
|
+
end
|
147
|
+
|
148
|
+
@location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
|
149
|
+
config.credentials = credentials
|
150
|
+
config.quota_project = @quota_project_id
|
151
|
+
config.endpoint = @config.endpoint
|
152
|
+
end
|
153
|
+
|
154
|
+
@completion_service_stub = ::Google::Cloud::Retail::V2::CompletionService::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
|
155
|
+
end
|
156
|
+
|
157
|
+
##
|
158
|
+
# Get the associated client for long-running operations.
|
159
|
+
#
|
160
|
+
# @return [::Google::Cloud::Retail::V2::CompletionService::Rest::Operations]
|
161
|
+
#
|
162
|
+
attr_reader :operations_client
|
163
|
+
|
164
|
+
##
|
165
|
+
# Get the associated client for mix-in of the Locations.
|
166
|
+
#
|
167
|
+
# @return [Google::Cloud::Location::Locations::Rest::Client]
|
168
|
+
#
|
169
|
+
attr_reader :location_client
|
170
|
+
|
171
|
+
# Service calls
|
172
|
+
|
173
|
+
##
|
174
|
+
# Completes the specified prefix with keyword suggestions.
|
175
|
+
#
|
176
|
+
# This feature is only available for users who have Retail Search enabled.
|
177
|
+
# Enable Retail Search on Cloud Console before using this feature.
|
178
|
+
#
|
179
|
+
# @overload complete_query(request, options = nil)
|
180
|
+
# Pass arguments to `complete_query` via a request object, either of type
|
181
|
+
# {::Google::Cloud::Retail::V2::CompleteQueryRequest} or an equivalent Hash.
|
182
|
+
#
|
183
|
+
# @param request [::Google::Cloud::Retail::V2::CompleteQueryRequest, ::Hash]
|
184
|
+
# A request object representing the call parameters. Required. To specify no
|
185
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
186
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
187
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
188
|
+
#
|
189
|
+
# @overload complete_query(catalog: nil, query: nil, visitor_id: nil, language_codes: nil, device_type: nil, dataset: nil, max_suggestions: nil)
|
190
|
+
# Pass arguments to `complete_query` via keyword arguments. Note that at
|
191
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
192
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
193
|
+
#
|
194
|
+
# @param catalog [::String]
|
195
|
+
# Required. Catalog for which the completion is performed.
|
196
|
+
#
|
197
|
+
# Full resource name of catalog, such as
|
198
|
+
# `projects/*/locations/global/catalogs/default_catalog`.
|
199
|
+
# @param query [::String]
|
200
|
+
# Required. The query used to generate suggestions.
|
201
|
+
#
|
202
|
+
# The maximum number of allowed characters is 255.
|
203
|
+
# @param visitor_id [::String]
|
204
|
+
# Required field. A unique identifier for tracking visitors. For example,
|
205
|
+
# this could be implemented with an HTTP cookie, which should be able to
|
206
|
+
# uniquely identify a visitor on a single device. This unique identifier
|
207
|
+
# should not change if the visitor logs in or out of the website.
|
208
|
+
#
|
209
|
+
# The field must be a UTF-8 encoded string with a length limit of 128
|
210
|
+
# characters. Otherwise, an INVALID_ARGUMENT error is returned.
|
211
|
+
# @param language_codes [::Array<::String>]
|
212
|
+
# Note that this field applies for `user-data` dataset only. For requests
|
213
|
+
# with `cloud-retail` dataset, setting this field has no effect.
|
214
|
+
#
|
215
|
+
# The language filters applied to the output suggestions. If set, it should
|
216
|
+
# contain the language of the query. If not set, suggestions are returned
|
217
|
+
# without considering language restrictions. This is the BCP-47 language
|
218
|
+
# code, such as "en-US" or "sr-Latn". For more information, see [Tags for
|
219
|
+
# Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum
|
220
|
+
# number of language codes is 3.
|
221
|
+
# @param device_type [::String]
|
222
|
+
# The device type context for completion suggestions. We recommend that you
|
223
|
+
# leave this field empty.
|
224
|
+
#
|
225
|
+
# It can apply different suggestions on different device types, e.g.
|
226
|
+
# `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device
|
227
|
+
# types.
|
228
|
+
#
|
229
|
+
# Supported formats:
|
230
|
+
#
|
231
|
+
# * `UNKNOWN_DEVICE_TYPE`
|
232
|
+
#
|
233
|
+
# * `DESKTOP`
|
234
|
+
#
|
235
|
+
# * `MOBILE`
|
236
|
+
#
|
237
|
+
# * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`.
|
238
|
+
# @param dataset [::String]
|
239
|
+
# Determines which dataset to use for fetching completion. "user-data" will
|
240
|
+
# use the imported dataset through
|
241
|
+
# {::Google::Cloud::Retail::V2::CompletionService::Rest::Client#import_completion_data CompletionService.ImportCompletionData}.
|
242
|
+
# "cloud-retail" will use the dataset generated by cloud retail based on user
|
243
|
+
# events. If leave empty, it will use the "user-data".
|
244
|
+
#
|
245
|
+
# Current supported values:
|
246
|
+
#
|
247
|
+
# * user-data
|
248
|
+
#
|
249
|
+
# * cloud-retail:
|
250
|
+
# This option requires enabling auto-learning function first. See
|
251
|
+
# [guidelines](https://cloud.google.com/retail/docs/completion-overview#generated-completion-dataset).
|
252
|
+
# @param max_suggestions [::Integer]
|
253
|
+
# Completion max suggestions. If left unset or set to 0, then will fallback
|
254
|
+
# to the configured value
|
255
|
+
# {::Google::Cloud::Retail::V2::CompletionConfig#max_suggestions CompletionConfig.max_suggestions}.
|
256
|
+
#
|
257
|
+
# The maximum allowed max suggestions is 20. If it is set higher, it will be
|
258
|
+
# capped by 20.
|
259
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
260
|
+
# @yieldparam result [::Google::Cloud::Retail::V2::CompleteQueryResponse]
|
261
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
262
|
+
#
|
263
|
+
# @return [::Google::Cloud::Retail::V2::CompleteQueryResponse]
|
264
|
+
#
|
265
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
266
|
+
def complete_query request, options = nil
|
267
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
268
|
+
|
269
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::CompleteQueryRequest
|
270
|
+
|
271
|
+
# Converts hash and nil to an options object
|
272
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
273
|
+
|
274
|
+
# Customize the options with defaults
|
275
|
+
call_metadata = @config.rpcs.complete_query.metadata.to_h
|
276
|
+
|
277
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
278
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
279
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
280
|
+
gapic_version: ::Google::Cloud::Retail::V2::VERSION,
|
281
|
+
transports_version_send: [:rest]
|
282
|
+
|
283
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
284
|
+
|
285
|
+
options.apply_defaults timeout: @config.rpcs.complete_query.timeout,
|
286
|
+
metadata: call_metadata,
|
287
|
+
retry_policy: @config.rpcs.complete_query.retry_policy
|
288
|
+
|
289
|
+
options.apply_defaults timeout: @config.timeout,
|
290
|
+
metadata: @config.metadata,
|
291
|
+
retry_policy: @config.retry_policy
|
292
|
+
|
293
|
+
@completion_service_stub.complete_query request, options do |result, operation|
|
294
|
+
yield result, operation if block_given?
|
295
|
+
return result
|
296
|
+
end
|
297
|
+
rescue ::Gapic::Rest::Error => e
|
298
|
+
raise ::Google::Cloud::Error.from_error(e)
|
299
|
+
end
|
300
|
+
|
301
|
+
##
|
302
|
+
# Bulk import of processed completion dataset.
|
303
|
+
#
|
304
|
+
# Request processing is asynchronous. Partial updating is not supported.
|
305
|
+
#
|
306
|
+
# The operation is successfully finished only after the imported suggestions
|
307
|
+
# are indexed successfully and ready for serving. The process takes hours.
|
308
|
+
#
|
309
|
+
# This feature is only available for users who have Retail Search enabled.
|
310
|
+
# Enable Retail Search on Cloud Console before using this feature.
|
311
|
+
#
|
312
|
+
# @overload import_completion_data(request, options = nil)
|
313
|
+
# Pass arguments to `import_completion_data` via a request object, either of type
|
314
|
+
# {::Google::Cloud::Retail::V2::ImportCompletionDataRequest} or an equivalent Hash.
|
315
|
+
#
|
316
|
+
# @param request [::Google::Cloud::Retail::V2::ImportCompletionDataRequest, ::Hash]
|
317
|
+
# A request object representing the call parameters. Required. To specify no
|
318
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
319
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
320
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
321
|
+
#
|
322
|
+
# @overload import_completion_data(parent: nil, input_config: nil, notification_pubsub_topic: nil)
|
323
|
+
# Pass arguments to `import_completion_data` via keyword arguments. Note that at
|
324
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
325
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
326
|
+
#
|
327
|
+
# @param parent [::String]
|
328
|
+
# Required. The catalog which the suggestions dataset belongs to.
|
329
|
+
#
|
330
|
+
# Format: `projects/1234/locations/global/catalogs/default_catalog`.
|
331
|
+
# @param input_config [::Google::Cloud::Retail::V2::CompletionDataInputConfig, ::Hash]
|
332
|
+
# Required. The desired input location of the data.
|
333
|
+
# @param notification_pubsub_topic [::String]
|
334
|
+
# Pub/Sub topic for receiving notification. If this field is set,
|
335
|
+
# when the import is finished, a notification is sent to
|
336
|
+
# specified Pub/Sub topic. The message data is JSON string of a
|
337
|
+
# {::Google::Longrunning::Operation Operation}.
|
338
|
+
# Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`.
|
339
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
340
|
+
# @yieldparam result [::Gapic::Operation]
|
341
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
342
|
+
#
|
343
|
+
# @return [::Gapic::Operation]
|
344
|
+
#
|
345
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
346
|
+
def import_completion_data request, options = nil
|
347
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
348
|
+
|
349
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::ImportCompletionDataRequest
|
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
|
+
call_metadata = @config.rpcs.import_completion_data.metadata.to_h
|
356
|
+
|
357
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
358
|
+
call_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::Retail::V2::VERSION,
|
361
|
+
transports_version_send: [:rest]
|
362
|
+
|
363
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
364
|
+
|
365
|
+
options.apply_defaults timeout: @config.rpcs.import_completion_data.timeout,
|
366
|
+
metadata: call_metadata,
|
367
|
+
retry_policy: @config.rpcs.import_completion_data.retry_policy
|
368
|
+
|
369
|
+
options.apply_defaults timeout: @config.timeout,
|
370
|
+
metadata: @config.metadata,
|
371
|
+
retry_policy: @config.retry_policy
|
372
|
+
|
373
|
+
@completion_service_stub.import_completion_data request, options do |result, operation|
|
374
|
+
result = ::Gapic::Operation.new result, @operations_client, options: options
|
375
|
+
yield result, operation if block_given?
|
376
|
+
return result
|
377
|
+
end
|
378
|
+
rescue ::Gapic::Rest::Error => e
|
379
|
+
raise ::Google::Cloud::Error.from_error(e)
|
380
|
+
end
|
381
|
+
|
382
|
+
##
|
383
|
+
# Configuration class for the CompletionService REST API.
|
384
|
+
#
|
385
|
+
# This class represents the configuration for CompletionService REST,
|
386
|
+
# providing control over timeouts, retry behavior, logging, transport
|
387
|
+
# parameters, and other low-level controls. Certain parameters can also be
|
388
|
+
# applied individually to specific RPCs. See
|
389
|
+
# {::Google::Cloud::Retail::V2::CompletionService::Rest::Client::Configuration::Rpcs}
|
390
|
+
# for a list of RPCs that can be configured independently.
|
391
|
+
#
|
392
|
+
# Configuration can be applied globally to all clients, or to a single client
|
393
|
+
# on construction.
|
394
|
+
#
|
395
|
+
# @example
|
396
|
+
#
|
397
|
+
# # Modify the global config, setting the timeout for
|
398
|
+
# # complete_query to 20 seconds,
|
399
|
+
# # and all remaining timeouts to 10 seconds.
|
400
|
+
# ::Google::Cloud::Retail::V2::CompletionService::Rest::Client.configure do |config|
|
401
|
+
# config.timeout = 10.0
|
402
|
+
# config.rpcs.complete_query.timeout = 20.0
|
403
|
+
# end
|
404
|
+
#
|
405
|
+
# # Apply the above configuration only to a new client.
|
406
|
+
# client = ::Google::Cloud::Retail::V2::CompletionService::Rest::Client.new do |config|
|
407
|
+
# config.timeout = 10.0
|
408
|
+
# config.rpcs.complete_query.timeout = 20.0
|
409
|
+
# end
|
410
|
+
#
|
411
|
+
# @!attribute [rw] endpoint
|
412
|
+
# The hostname or hostname:port of the service endpoint.
|
413
|
+
# Defaults to `"retail.googleapis.com"`.
|
414
|
+
# @return [::String]
|
415
|
+
# @!attribute [rw] credentials
|
416
|
+
# Credentials to send with calls. You may provide any of the following types:
|
417
|
+
# * (`String`) The path to a service account key file in JSON format
|
418
|
+
# * (`Hash`) A service account key as a Hash
|
419
|
+
# * (`Google::Auth::Credentials`) A googleauth credentials object
|
420
|
+
# (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
|
421
|
+
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
|
422
|
+
# (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
|
423
|
+
# * (`nil`) indicating no credentials
|
424
|
+
# @return [::Object]
|
425
|
+
# @!attribute [rw] scope
|
426
|
+
# The OAuth scopes
|
427
|
+
# @return [::Array<::String>]
|
428
|
+
# @!attribute [rw] lib_name
|
429
|
+
# The library name as recorded in instrumentation and logging
|
430
|
+
# @return [::String]
|
431
|
+
# @!attribute [rw] lib_version
|
432
|
+
# The library version as recorded in instrumentation and logging
|
433
|
+
# @return [::String]
|
434
|
+
# @!attribute [rw] timeout
|
435
|
+
# The call timeout in seconds.
|
436
|
+
# @return [::Numeric]
|
437
|
+
# @!attribute [rw] metadata
|
438
|
+
# Additional headers to be sent with the call.
|
439
|
+
# @return [::Hash{::Symbol=>::String}]
|
440
|
+
# @!attribute [rw] retry_policy
|
441
|
+
# The retry policy. The value is a hash with the following keys:
|
442
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
443
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
444
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
445
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
446
|
+
# trigger a retry.
|
447
|
+
# @return [::Hash]
|
448
|
+
# @!attribute [rw] quota_project
|
449
|
+
# A separate project against which to charge quota.
|
450
|
+
# @return [::String]
|
451
|
+
#
|
452
|
+
class Configuration
|
453
|
+
extend ::Gapic::Config
|
454
|
+
|
455
|
+
config_attr :endpoint, "retail.googleapis.com", ::String
|
456
|
+
config_attr :credentials, nil do |value|
|
457
|
+
allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
|
458
|
+
allowed.any? { |klass| klass === value }
|
459
|
+
end
|
460
|
+
config_attr :scope, nil, ::String, ::Array, nil
|
461
|
+
config_attr :lib_name, nil, ::String, nil
|
462
|
+
config_attr :lib_version, nil, ::String, nil
|
463
|
+
config_attr :timeout, nil, ::Numeric, nil
|
464
|
+
config_attr :metadata, nil, ::Hash, nil
|
465
|
+
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
466
|
+
config_attr :quota_project, nil, ::String, nil
|
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 CompletionService 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 `complete_query`
|
507
|
+
# @return [::Gapic::Config::Method]
|
508
|
+
#
|
509
|
+
attr_reader :complete_query
|
510
|
+
##
|
511
|
+
# RPC-specific configuration for `import_completion_data`
|
512
|
+
# @return [::Gapic::Config::Method]
|
513
|
+
#
|
514
|
+
attr_reader :import_completion_data
|
515
|
+
|
516
|
+
# @private
|
517
|
+
def initialize parent_rpcs = nil
|
518
|
+
complete_query_config = parent_rpcs.complete_query if parent_rpcs.respond_to? :complete_query
|
519
|
+
@complete_query = ::Gapic::Config::Method.new complete_query_config
|
520
|
+
import_completion_data_config = parent_rpcs.import_completion_data if parent_rpcs.respond_to? :import_completion_data
|
521
|
+
@import_completion_data = ::Gapic::Config::Method.new import_completion_data_config
|
522
|
+
|
523
|
+
yield self if block_given?
|
524
|
+
end
|
525
|
+
end
|
526
|
+
end
|
527
|
+
end
|
528
|
+
end
|
529
|
+
end
|
530
|
+
end
|
531
|
+
end
|
532
|
+
end
|
533
|
+
end
|