google-cloud-recommendation_engine-v1beta1 0.4.1 → 0.6.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 +2 -2
- data/lib/google/cloud/recommendation_engine/v1beta1/catalog_service/client.rb +10 -12
- data/lib/google/cloud/recommendation_engine/v1beta1/catalog_service/operations.rb +14 -16
- data/lib/google/cloud/recommendation_engine/v1beta1/catalog_service/rest/client.rb +769 -0
- data/lib/google/cloud/recommendation_engine/v1beta1/catalog_service/rest/operations.rb +807 -0
- data/lib/google/cloud/recommendation_engine/v1beta1/catalog_service/rest/service_stub.rb +405 -0
- data/lib/google/cloud/recommendation_engine/v1beta1/catalog_service/rest.rb +53 -0
- data/lib/google/cloud/recommendation_engine/v1beta1/catalog_service.rb +7 -1
- data/lib/google/cloud/recommendation_engine/v1beta1/prediction_api_key_registry/client.rb +6 -8
- data/lib/google/cloud/recommendation_engine/v1beta1/prediction_api_key_registry/rest/client.rb +512 -0
- data/lib/google/cloud/recommendation_engine/v1beta1/prediction_api_key_registry/rest/service_stub.rb +226 -0
- data/lib/google/cloud/recommendation_engine/v1beta1/prediction_api_key_registry/rest.rb +56 -0
- data/lib/google/cloud/recommendation_engine/v1beta1/prediction_api_key_registry.rb +7 -1
- data/lib/google/cloud/recommendation_engine/v1beta1/prediction_service/client.rb +6 -8
- data/lib/google/cloud/recommendation_engine/v1beta1/prediction_service/rest/client.rb +440 -0
- data/lib/google/cloud/recommendation_engine/v1beta1/prediction_service/rest/service_stub.rb +108 -0
- data/lib/google/cloud/recommendation_engine/v1beta1/prediction_service/rest.rb +52 -0
- data/lib/google/cloud/recommendation_engine/v1beta1/prediction_service.rb +7 -1
- data/lib/google/cloud/recommendation_engine/v1beta1/rest.rb +40 -0
- data/lib/google/cloud/recommendation_engine/v1beta1/user_event_service/client.rb +14 -16
- data/lib/google/cloud/recommendation_engine/v1beta1/user_event_service/operations.rb +14 -16
- data/lib/google/cloud/recommendation_engine/v1beta1/user_event_service/rest/client.rb +765 -0
- data/lib/google/cloud/recommendation_engine/v1beta1/user_event_service/rest/operations.rb +807 -0
- data/lib/google/cloud/recommendation_engine/v1beta1/user_event_service/rest/service_stub.rb +346 -0
- data/lib/google/cloud/recommendation_engine/v1beta1/user_event_service/rest.rb +53 -0
- data/lib/google/cloud/recommendation_engine/v1beta1/user_event_service.rb +7 -1
- data/lib/google/cloud/recommendation_engine/v1beta1/version.rb +1 -1
- data/lib/google/cloud/recommendation_engine/v1beta1.rb +7 -2
- data/lib/google/cloud/recommendationengine/v1beta1/catalog_pb.rb +25 -49
- data/lib/google/cloud/recommendationengine/v1beta1/catalog_service_pb.rb +26 -26
- data/lib/google/cloud/recommendationengine/v1beta1/common_pb.rb +24 -11
- data/lib/google/cloud/recommendationengine/v1beta1/import_pb.rb +28 -55
- data/lib/google/cloud/recommendationengine/v1beta1/prediction_apikey_registry_service_pb.rb +24 -20
- data/lib/google/cloud/recommendationengine/v1beta1/prediction_service_pb.rb +26 -23
- data/lib/google/cloud/recommendationengine/v1beta1/recommendationengine_resources_pb.rb +25 -2
- data/lib/google/cloud/recommendationengine/v1beta1/user_event_pb.rb +27 -55
- data/lib/google/cloud/recommendationengine/v1beta1/user_event_service_pb.rb +26 -34
- data/proto_docs/google/api/client.rb +67 -4
- data/proto_docs/google/protobuf/any.rb +7 -4
- data/proto_docs/google/protobuf/struct.rb +1 -1
- data/proto_docs/google/protobuf/timestamp.rb +1 -3
- data/proto_docs/google/rpc/status.rb +4 -2
- metadata +25 -8
@@ -0,0 +1,440 @@
|
|
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/recommendationengine/v1beta1/prediction_service_pb"
|
21
|
+
require "google/cloud/recommendation_engine/v1beta1/prediction_service/rest/service_stub"
|
22
|
+
|
23
|
+
module Google
|
24
|
+
module Cloud
|
25
|
+
module RecommendationEngine
|
26
|
+
module V1beta1
|
27
|
+
module PredictionService
|
28
|
+
module Rest
|
29
|
+
##
|
30
|
+
# REST client for the PredictionService service.
|
31
|
+
#
|
32
|
+
# Service for making recommendation prediction.
|
33
|
+
#
|
34
|
+
class Client
|
35
|
+
include Paths
|
36
|
+
|
37
|
+
# @private
|
38
|
+
attr_reader :prediction_service_stub
|
39
|
+
|
40
|
+
##
|
41
|
+
# Configure the PredictionService Client class.
|
42
|
+
#
|
43
|
+
# See {::Google::Cloud::RecommendationEngine::V1beta1::PredictionService::Rest::Client::Configuration}
|
44
|
+
# for a description of the configuration fields.
|
45
|
+
#
|
46
|
+
# @example
|
47
|
+
#
|
48
|
+
# # Modify the configuration for all PredictionService clients
|
49
|
+
# ::Google::Cloud::RecommendationEngine::V1beta1::PredictionService::Rest::Client.configure do |config|
|
50
|
+
# config.timeout = 10.0
|
51
|
+
# end
|
52
|
+
#
|
53
|
+
# @yield [config] Configure the Client client.
|
54
|
+
# @yieldparam config [Client::Configuration]
|
55
|
+
#
|
56
|
+
# @return [Client::Configuration]
|
57
|
+
#
|
58
|
+
def self.configure
|
59
|
+
@configure ||= begin
|
60
|
+
namespace = ["Google", "Cloud", "RecommendationEngine", "V1beta1"]
|
61
|
+
parent_config = while namespace.any?
|
62
|
+
parent_name = namespace.join "::"
|
63
|
+
parent_const = const_get parent_name
|
64
|
+
break parent_const.configure if parent_const.respond_to? :configure
|
65
|
+
namespace.pop
|
66
|
+
end
|
67
|
+
default_config = Client::Configuration.new parent_config
|
68
|
+
|
69
|
+
default_config.rpcs.predict.timeout = 600.0
|
70
|
+
default_config.rpcs.predict.retry_policy = {
|
71
|
+
initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
|
72
|
+
}
|
73
|
+
|
74
|
+
default_config
|
75
|
+
end
|
76
|
+
yield @configure if block_given?
|
77
|
+
@configure
|
78
|
+
end
|
79
|
+
|
80
|
+
##
|
81
|
+
# Configure the PredictionService Client instance.
|
82
|
+
#
|
83
|
+
# The configuration is set to the derived mode, meaning that values can be changed,
|
84
|
+
# but structural changes (adding new fields, etc.) are not allowed. Structural changes
|
85
|
+
# should be made on {Client.configure}.
|
86
|
+
#
|
87
|
+
# See {::Google::Cloud::RecommendationEngine::V1beta1::PredictionService::Rest::Client::Configuration}
|
88
|
+
# for a description of the configuration fields.
|
89
|
+
#
|
90
|
+
# @yield [config] Configure the Client client.
|
91
|
+
# @yieldparam config [Client::Configuration]
|
92
|
+
#
|
93
|
+
# @return [Client::Configuration]
|
94
|
+
#
|
95
|
+
def configure
|
96
|
+
yield @config if block_given?
|
97
|
+
@config
|
98
|
+
end
|
99
|
+
|
100
|
+
##
|
101
|
+
# Create a new PredictionService REST client object.
|
102
|
+
#
|
103
|
+
# @example
|
104
|
+
#
|
105
|
+
# # Create a client using the default configuration
|
106
|
+
# client = ::Google::Cloud::RecommendationEngine::V1beta1::PredictionService::Rest::Client.new
|
107
|
+
#
|
108
|
+
# # Create a client using a custom configuration
|
109
|
+
# client = ::Google::Cloud::RecommendationEngine::V1beta1::PredictionService::Rest::Client.new do |config|
|
110
|
+
# config.timeout = 10.0
|
111
|
+
# end
|
112
|
+
#
|
113
|
+
# @yield [config] Configure the PredictionService client.
|
114
|
+
# @yieldparam config [Client::Configuration]
|
115
|
+
#
|
116
|
+
def initialize
|
117
|
+
# Create the configuration object
|
118
|
+
@config = Configuration.new Client.configure
|
119
|
+
|
120
|
+
# Yield the configuration if needed
|
121
|
+
yield @config if block_given?
|
122
|
+
|
123
|
+
# Create credentials
|
124
|
+
credentials = @config.credentials
|
125
|
+
# Use self-signed JWT if the endpoint is unchanged from default,
|
126
|
+
# but only if the default endpoint does not have a region prefix.
|
127
|
+
enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
|
128
|
+
!@config.endpoint.split(".").first.include?("-")
|
129
|
+
credentials ||= Credentials.default scope: @config.scope,
|
130
|
+
enable_self_signed_jwt: enable_self_signed_jwt
|
131
|
+
if credentials.is_a?(::String) || credentials.is_a?(::Hash)
|
132
|
+
credentials = Credentials.new credentials, scope: @config.scope
|
133
|
+
end
|
134
|
+
|
135
|
+
@quota_project_id = @config.quota_project
|
136
|
+
@quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
|
137
|
+
|
138
|
+
@prediction_service_stub = ::Google::Cloud::RecommendationEngine::V1beta1::PredictionService::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
|
139
|
+
end
|
140
|
+
|
141
|
+
# Service calls
|
142
|
+
|
143
|
+
##
|
144
|
+
# Makes a recommendation prediction. If using API Key based authentication,
|
145
|
+
# the API Key must be registered using the
|
146
|
+
# {::Google::Cloud::RecommendationEngine::V1beta1::PredictionApiKeyRegistry::Rest::Client PredictionApiKeyRegistry}
|
147
|
+
# service. [Learn more](/recommendations-ai/docs/setting-up#register-key).
|
148
|
+
#
|
149
|
+
# @overload predict(request, options = nil)
|
150
|
+
# Pass arguments to `predict` via a request object, either of type
|
151
|
+
# {::Google::Cloud::RecommendationEngine::V1beta1::PredictRequest} or an equivalent Hash.
|
152
|
+
#
|
153
|
+
# @param request [::Google::Cloud::RecommendationEngine::V1beta1::PredictRequest, ::Hash]
|
154
|
+
# A request object representing the call parameters. Required. To specify no
|
155
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
156
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
157
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
158
|
+
#
|
159
|
+
# @overload predict(name: nil, user_event: nil, page_size: nil, page_token: nil, filter: nil, dry_run: nil, params: nil, labels: nil)
|
160
|
+
# Pass arguments to `predict` via keyword arguments. Note that at
|
161
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
162
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
163
|
+
#
|
164
|
+
# @param name [::String]
|
165
|
+
# Required. Full resource name of the format:
|
166
|
+
# `{name=projects/*/locations/global/catalogs/default_catalog/eventStores/default_event_store/placements/*}`
|
167
|
+
# The id of the recommendation engine placement. This id is used to identify
|
168
|
+
# the set of models that will be used to make the prediction.
|
169
|
+
#
|
170
|
+
# We currently support three placements with the following IDs by default:
|
171
|
+
#
|
172
|
+
# * `shopping_cart`: Predicts items frequently bought together with one or
|
173
|
+
# more catalog items in the same shopping session. Commonly displayed after
|
174
|
+
# `add-to-cart` events, on product detail pages, or on the shopping cart
|
175
|
+
# page.
|
176
|
+
#
|
177
|
+
# * `home_page`: Predicts the next product that a user will most likely
|
178
|
+
# engage with or purchase based on the shopping or viewing history of the
|
179
|
+
# specified `userId` or `visitorId`. For example - Recommendations for you.
|
180
|
+
#
|
181
|
+
# * `product_detail`: Predicts the next product that a user will most likely
|
182
|
+
# engage with or purchase. The prediction is based on the shopping or
|
183
|
+
# viewing history of the specified `userId` or `visitorId` and its
|
184
|
+
# relevance to a specified `CatalogItem`. Typically used on product detail
|
185
|
+
# pages. For example - More items like this.
|
186
|
+
#
|
187
|
+
# * `recently_viewed_default`: Returns up to 75 items recently viewed by the
|
188
|
+
# specified `userId` or `visitorId`, most recent ones first. Returns
|
189
|
+
# nothing if neither of them has viewed any items yet. For example -
|
190
|
+
# Recently viewed.
|
191
|
+
#
|
192
|
+
# The full list of available placements can be seen at
|
193
|
+
# https://console.cloud.google.com/recommendation/datafeeds/default_catalog/dashboard
|
194
|
+
# @param user_event [::Google::Cloud::RecommendationEngine::V1beta1::UserEvent, ::Hash]
|
195
|
+
# Required. Context about the user, what they are looking at and what action
|
196
|
+
# they took to trigger the predict request. Note that this user event detail
|
197
|
+
# won't be ingested to userEvent logs. Thus, a separate userEvent write
|
198
|
+
# request is required for event logging.
|
199
|
+
# @param page_size [::Integer]
|
200
|
+
# Optional. Maximum number of results to return per page. Set this property
|
201
|
+
# to the number of prediction results required. If zero, the service will
|
202
|
+
# choose a reasonable default.
|
203
|
+
# @param page_token [::String]
|
204
|
+
# Optional. The previous PredictResponse.next_page_token.
|
205
|
+
# @param filter [::String]
|
206
|
+
# Optional. Filter for restricting prediction results. Accepts values for
|
207
|
+
# tags and the `filterOutOfStockItems` flag.
|
208
|
+
#
|
209
|
+
# * Tag expressions. Restricts predictions to items that match all of the
|
210
|
+
# specified tags. Boolean operators `OR` and `NOT` are supported if the
|
211
|
+
# expression is enclosed in parentheses, and must be separated from the
|
212
|
+
# tag values by a space. `-"tagA"` is also supported and is equivalent to
|
213
|
+
# `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings
|
214
|
+
# with a size limit of 1 KiB.
|
215
|
+
#
|
216
|
+
# * filterOutOfStockItems. Restricts predictions to items that do not have a
|
217
|
+
# stockState value of OUT_OF_STOCK.
|
218
|
+
#
|
219
|
+
# Examples:
|
220
|
+
#
|
221
|
+
# * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional")
|
222
|
+
# * filterOutOfStockItems tag=(-"promotional")
|
223
|
+
# * filterOutOfStockItems
|
224
|
+
# @param dry_run [::Boolean]
|
225
|
+
# Optional. Use dryRun mode for this prediction query. If set to true, a
|
226
|
+
# dummy model will be used that returns arbitrary catalog items.
|
227
|
+
# Note that the dryRun mode should only be used for testing the API, or if
|
228
|
+
# the model is not ready.
|
229
|
+
# @param params [::Hash{::String => ::Google::Protobuf::Value, ::Hash}]
|
230
|
+
# Optional. Additional domain specific parameters for the predictions.
|
231
|
+
#
|
232
|
+
# Allowed values:
|
233
|
+
#
|
234
|
+
# * `returnCatalogItem`: Boolean. If set to true, the associated catalogItem
|
235
|
+
# object will be returned in the
|
236
|
+
# `PredictResponse.PredictionResult.itemMetadata` object in the method
|
237
|
+
# response.
|
238
|
+
# * `returnItemScore`: Boolean. If set to true, the prediction 'score'
|
239
|
+
# corresponding to each returned item will be set in the `metadata`
|
240
|
+
# field in the prediction response. The given 'score' indicates the
|
241
|
+
# probability of an item being clicked/purchased given the user's context
|
242
|
+
# and history.
|
243
|
+
# @param labels [::Hash{::String => ::String}]
|
244
|
+
# Optional. The labels for the predict request.
|
245
|
+
#
|
246
|
+
# * Label keys can contain lowercase letters, digits and hyphens, must start
|
247
|
+
# with a letter, and must end with a letter or digit.
|
248
|
+
# * Non-zero label values can contain lowercase letters, digits and hyphens,
|
249
|
+
# must start with a letter, and must end with a letter or digit.
|
250
|
+
# * No more than 64 labels can be associated with a given request.
|
251
|
+
#
|
252
|
+
# See https://goo.gl/xmQnxf for more information on and examples of labels.
|
253
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
254
|
+
# @yieldparam result [::Gapic::Rest::PagedEnumerable<::String, ::Google::Protobuf::Value>]
|
255
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
256
|
+
#
|
257
|
+
# @return [::Gapic::Rest::PagedEnumerable<::String, ::Google::Protobuf::Value>]
|
258
|
+
#
|
259
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
260
|
+
def predict request, options = nil
|
261
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
262
|
+
|
263
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::RecommendationEngine::V1beta1::PredictRequest
|
264
|
+
|
265
|
+
# Converts hash and nil to an options object
|
266
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
267
|
+
|
268
|
+
# Customize the options with defaults
|
269
|
+
call_metadata = @config.rpcs.predict.metadata.to_h
|
270
|
+
|
271
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
272
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
273
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
274
|
+
gapic_version: ::Google::Cloud::RecommendationEngine::V1beta1::VERSION,
|
275
|
+
transports_version_send: [:rest]
|
276
|
+
|
277
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
278
|
+
|
279
|
+
options.apply_defaults timeout: @config.rpcs.predict.timeout,
|
280
|
+
metadata: call_metadata,
|
281
|
+
retry_policy: @config.rpcs.predict.retry_policy
|
282
|
+
|
283
|
+
options.apply_defaults timeout: @config.timeout,
|
284
|
+
metadata: @config.metadata,
|
285
|
+
retry_policy: @config.retry_policy
|
286
|
+
|
287
|
+
@prediction_service_stub.predict request, options do |result, operation|
|
288
|
+
result = ::Gapic::Rest::PagedEnumerable.new @prediction_service_stub, :predict, "metadata", request, result, options
|
289
|
+
yield result, operation if block_given?
|
290
|
+
return result
|
291
|
+
end
|
292
|
+
rescue ::Gapic::Rest::Error => e
|
293
|
+
raise ::Google::Cloud::Error.from_error(e)
|
294
|
+
end
|
295
|
+
|
296
|
+
##
|
297
|
+
# Configuration class for the PredictionService REST API.
|
298
|
+
#
|
299
|
+
# This class represents the configuration for PredictionService REST,
|
300
|
+
# providing control over timeouts, retry behavior, logging, transport
|
301
|
+
# parameters, and other low-level controls. Certain parameters can also be
|
302
|
+
# applied individually to specific RPCs. See
|
303
|
+
# {::Google::Cloud::RecommendationEngine::V1beta1::PredictionService::Rest::Client::Configuration::Rpcs}
|
304
|
+
# for a list of RPCs that can be configured independently.
|
305
|
+
#
|
306
|
+
# Configuration can be applied globally to all clients, or to a single client
|
307
|
+
# on construction.
|
308
|
+
#
|
309
|
+
# @example
|
310
|
+
#
|
311
|
+
# # Modify the global config, setting the timeout for
|
312
|
+
# # predict to 20 seconds,
|
313
|
+
# # and all remaining timeouts to 10 seconds.
|
314
|
+
# ::Google::Cloud::RecommendationEngine::V1beta1::PredictionService::Rest::Client.configure do |config|
|
315
|
+
# config.timeout = 10.0
|
316
|
+
# config.rpcs.predict.timeout = 20.0
|
317
|
+
# end
|
318
|
+
#
|
319
|
+
# # Apply the above configuration only to a new client.
|
320
|
+
# client = ::Google::Cloud::RecommendationEngine::V1beta1::PredictionService::Rest::Client.new do |config|
|
321
|
+
# config.timeout = 10.0
|
322
|
+
# config.rpcs.predict.timeout = 20.0
|
323
|
+
# end
|
324
|
+
#
|
325
|
+
# @!attribute [rw] endpoint
|
326
|
+
# The hostname or hostname:port of the service endpoint.
|
327
|
+
# Defaults to `"recommendationengine.googleapis.com"`.
|
328
|
+
# @return [::String]
|
329
|
+
# @!attribute [rw] credentials
|
330
|
+
# Credentials to send with calls. You may provide any of the following types:
|
331
|
+
# * (`String`) The path to a service account key file in JSON format
|
332
|
+
# * (`Hash`) A service account key as a Hash
|
333
|
+
# * (`Google::Auth::Credentials`) A googleauth credentials object
|
334
|
+
# (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
|
335
|
+
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
|
336
|
+
# (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
|
337
|
+
# * (`nil`) indicating no credentials
|
338
|
+
# @return [::Object]
|
339
|
+
# @!attribute [rw] scope
|
340
|
+
# The OAuth scopes
|
341
|
+
# @return [::Array<::String>]
|
342
|
+
# @!attribute [rw] lib_name
|
343
|
+
# The library name as recorded in instrumentation and logging
|
344
|
+
# @return [::String]
|
345
|
+
# @!attribute [rw] lib_version
|
346
|
+
# The library version as recorded in instrumentation and logging
|
347
|
+
# @return [::String]
|
348
|
+
# @!attribute [rw] timeout
|
349
|
+
# The call timeout in seconds.
|
350
|
+
# @return [::Numeric]
|
351
|
+
# @!attribute [rw] metadata
|
352
|
+
# Additional headers to be sent with the call.
|
353
|
+
# @return [::Hash{::Symbol=>::String}]
|
354
|
+
# @!attribute [rw] retry_policy
|
355
|
+
# The retry policy. The value is a hash with the following keys:
|
356
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
357
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
358
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
359
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
360
|
+
# trigger a retry.
|
361
|
+
# @return [::Hash]
|
362
|
+
# @!attribute [rw] quota_project
|
363
|
+
# A separate project against which to charge quota.
|
364
|
+
# @return [::String]
|
365
|
+
#
|
366
|
+
class Configuration
|
367
|
+
extend ::Gapic::Config
|
368
|
+
|
369
|
+
config_attr :endpoint, "recommendationengine.googleapis.com", ::String
|
370
|
+
config_attr :credentials, nil do |value|
|
371
|
+
allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
|
372
|
+
allowed.any? { |klass| klass === value }
|
373
|
+
end
|
374
|
+
config_attr :scope, nil, ::String, ::Array, nil
|
375
|
+
config_attr :lib_name, nil, ::String, nil
|
376
|
+
config_attr :lib_version, nil, ::String, nil
|
377
|
+
config_attr :timeout, nil, ::Numeric, nil
|
378
|
+
config_attr :metadata, nil, ::Hash, nil
|
379
|
+
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
380
|
+
config_attr :quota_project, nil, ::String, nil
|
381
|
+
|
382
|
+
# @private
|
383
|
+
def initialize parent_config = nil
|
384
|
+
@parent_config = parent_config unless parent_config.nil?
|
385
|
+
|
386
|
+
yield self if block_given?
|
387
|
+
end
|
388
|
+
|
389
|
+
##
|
390
|
+
# Configurations for individual RPCs
|
391
|
+
# @return [Rpcs]
|
392
|
+
#
|
393
|
+
def rpcs
|
394
|
+
@rpcs ||= begin
|
395
|
+
parent_rpcs = nil
|
396
|
+
parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
|
397
|
+
Rpcs.new parent_rpcs
|
398
|
+
end
|
399
|
+
end
|
400
|
+
|
401
|
+
##
|
402
|
+
# Configuration RPC class for the PredictionService API.
|
403
|
+
#
|
404
|
+
# Includes fields providing the configuration for each RPC in this service.
|
405
|
+
# Each configuration object is of type `Gapic::Config::Method` and includes
|
406
|
+
# the following configuration fields:
|
407
|
+
#
|
408
|
+
# * `timeout` (*type:* `Numeric`) - The call timeout in seconds
|
409
|
+
# * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
|
410
|
+
# * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
|
411
|
+
# include the following keys:
|
412
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
413
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
414
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
415
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
416
|
+
# trigger a retry.
|
417
|
+
#
|
418
|
+
class Rpcs
|
419
|
+
##
|
420
|
+
# RPC-specific configuration for `predict`
|
421
|
+
# @return [::Gapic::Config::Method]
|
422
|
+
#
|
423
|
+
attr_reader :predict
|
424
|
+
|
425
|
+
# @private
|
426
|
+
def initialize parent_rpcs = nil
|
427
|
+
predict_config = parent_rpcs.predict if parent_rpcs.respond_to? :predict
|
428
|
+
@predict = ::Gapic::Config::Method.new predict_config
|
429
|
+
|
430
|
+
yield self if block_given?
|
431
|
+
end
|
432
|
+
end
|
433
|
+
end
|
434
|
+
end
|
435
|
+
end
|
436
|
+
end
|
437
|
+
end
|
438
|
+
end
|
439
|
+
end
|
440
|
+
end
|
@@ -0,0 +1,108 @@
|
|
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/recommendationengine/v1beta1/prediction_service_pb"
|
20
|
+
|
21
|
+
module Google
|
22
|
+
module Cloud
|
23
|
+
module RecommendationEngine
|
24
|
+
module V1beta1
|
25
|
+
module PredictionService
|
26
|
+
module Rest
|
27
|
+
##
|
28
|
+
# REST service stub for the PredictionService service.
|
29
|
+
# Service stub contains baseline method implementations
|
30
|
+
# including transcoding, making the REST call, and deserialing the response.
|
31
|
+
#
|
32
|
+
class ServiceStub
|
33
|
+
def initialize endpoint:, credentials:
|
34
|
+
# These require statements are intentionally placed here to initialize
|
35
|
+
# the REST modules only when it's required.
|
36
|
+
require "gapic/rest"
|
37
|
+
|
38
|
+
@client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, credentials: credentials,
|
39
|
+
numeric_enums: true,
|
40
|
+
raise_faraday_errors: false
|
41
|
+
end
|
42
|
+
|
43
|
+
##
|
44
|
+
# Baseline implementation for the predict REST call
|
45
|
+
#
|
46
|
+
# @param request_pb [::Google::Cloud::RecommendationEngine::V1beta1::PredictRequest]
|
47
|
+
# A request object representing the call parameters. Required.
|
48
|
+
# @param options [::Gapic::CallOptions]
|
49
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
50
|
+
#
|
51
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
52
|
+
# @yieldparam result [::Google::Cloud::RecommendationEngine::V1beta1::PredictResponse]
|
53
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
54
|
+
#
|
55
|
+
# @return [::Google::Cloud::RecommendationEngine::V1beta1::PredictResponse]
|
56
|
+
# A result object deserialized from the server's reply
|
57
|
+
def predict request_pb, options = nil
|
58
|
+
raise ::ArgumentError, "request must be provided" if request_pb.nil?
|
59
|
+
|
60
|
+
verb, uri, query_string_params, body = ServiceStub.transcode_predict_request request_pb
|
61
|
+
query_string_params = if query_string_params.any?
|
62
|
+
query_string_params.to_h { |p| p.split("=", 2) }
|
63
|
+
else
|
64
|
+
{}
|
65
|
+
end
|
66
|
+
|
67
|
+
response = @client_stub.make_http_request(
|
68
|
+
verb,
|
69
|
+
uri: uri,
|
70
|
+
body: body || "",
|
71
|
+
params: query_string_params,
|
72
|
+
options: options
|
73
|
+
)
|
74
|
+
operation = ::Gapic::Rest::TransportOperation.new response
|
75
|
+
result = ::Google::Cloud::RecommendationEngine::V1beta1::PredictResponse.decode_json response.body, ignore_unknown_fields: true
|
76
|
+
|
77
|
+
yield result, operation if block_given?
|
78
|
+
result
|
79
|
+
end
|
80
|
+
|
81
|
+
##
|
82
|
+
# @private
|
83
|
+
#
|
84
|
+
# GRPC transcoding helper method for the predict REST call
|
85
|
+
#
|
86
|
+
# @param request_pb [::Google::Cloud::RecommendationEngine::V1beta1::PredictRequest]
|
87
|
+
# A request object representing the call parameters. Required.
|
88
|
+
# @return [Array(String, [String, nil], Hash{String => String})]
|
89
|
+
# Uri, Body, Query string parameters
|
90
|
+
def self.transcode_predict_request request_pb
|
91
|
+
transcoder = Gapic::Rest::GrpcTranscoder.new
|
92
|
+
.with_bindings(
|
93
|
+
uri_method: :post,
|
94
|
+
uri_template: "/v1beta1/{name}:predict",
|
95
|
+
body: "*",
|
96
|
+
matches: [
|
97
|
+
["name", %r{^projects/[^/]+/locations/[^/]+/catalogs/[^/]+/eventStores/[^/]+/placements/[^/]+/?$}, false]
|
98
|
+
]
|
99
|
+
)
|
100
|
+
transcoder.transcode request_pb
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -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/recommendation_engine/v1beta1/version"
|
24
|
+
|
25
|
+
require "google/cloud/recommendation_engine/v1beta1/prediction_service/credentials"
|
26
|
+
require "google/cloud/recommendation_engine/v1beta1/prediction_service/paths"
|
27
|
+
require "google/cloud/recommendation_engine/v1beta1/prediction_service/rest/client"
|
28
|
+
|
29
|
+
module Google
|
30
|
+
module Cloud
|
31
|
+
module RecommendationEngine
|
32
|
+
module V1beta1
|
33
|
+
##
|
34
|
+
# Service for making recommendation prediction.
|
35
|
+
#
|
36
|
+
# To load this service and instantiate a REST client:
|
37
|
+
#
|
38
|
+
# require "google/cloud/recommendation_engine/v1beta1/prediction_service/rest"
|
39
|
+
# client = ::Google::Cloud::RecommendationEngine::V1beta1::PredictionService::Rest::Client.new
|
40
|
+
#
|
41
|
+
module PredictionService
|
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/recommendation_engine/v1beta1/prediction_service/rest/helpers" if ::File.file? helper_path
|
@@ -25,6 +25,7 @@ require "google/cloud/recommendation_engine/v1beta1/version"
|
|
25
25
|
require "google/cloud/recommendation_engine/v1beta1/prediction_service/credentials"
|
26
26
|
require "google/cloud/recommendation_engine/v1beta1/prediction_service/paths"
|
27
27
|
require "google/cloud/recommendation_engine/v1beta1/prediction_service/client"
|
28
|
+
require "google/cloud/recommendation_engine/v1beta1/prediction_service/rest"
|
28
29
|
|
29
30
|
module Google
|
30
31
|
module Cloud
|
@@ -33,11 +34,16 @@ module Google
|
|
33
34
|
##
|
34
35
|
# Service for making recommendation prediction.
|
35
36
|
#
|
36
|
-
#
|
37
|
+
# @example Load this service and instantiate a gRPC client
|
37
38
|
#
|
38
39
|
# require "google/cloud/recommendation_engine/v1beta1/prediction_service"
|
39
40
|
# client = ::Google::Cloud::RecommendationEngine::V1beta1::PredictionService::Client.new
|
40
41
|
#
|
42
|
+
# @example Load this service and instantiate a REST client
|
43
|
+
#
|
44
|
+
# require "google/cloud/recommendation_engine/v1beta1/prediction_service/rest"
|
45
|
+
# client = ::Google::Cloud::RecommendationEngine::V1beta1::PredictionService::Rest::Client.new
|
46
|
+
#
|
41
47
|
module PredictionService
|
42
48
|
end
|
43
49
|
end
|
@@ -0,0 +1,40 @@
|
|
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/recommendation_engine/v1beta1/catalog_service/rest"
|
20
|
+
require "google/cloud/recommendation_engine/v1beta1/prediction_api_key_registry/rest"
|
21
|
+
require "google/cloud/recommendation_engine/v1beta1/prediction_service/rest"
|
22
|
+
require "google/cloud/recommendation_engine/v1beta1/user_event_service/rest"
|
23
|
+
require "google/cloud/recommendation_engine/v1beta1/version"
|
24
|
+
|
25
|
+
module Google
|
26
|
+
module Cloud
|
27
|
+
module RecommendationEngine
|
28
|
+
##
|
29
|
+
# To load just the REST part of this package, including all its services, and instantiate a REST client:
|
30
|
+
#
|
31
|
+
# @example
|
32
|
+
#
|
33
|
+
# require "google/cloud/recommendation_engine/v1beta1/rest"
|
34
|
+
# client = ::Google::Cloud::RecommendationEngine::V1beta1::CatalogService::Rest::Client.new
|
35
|
+
#
|
36
|
+
module V1beta1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|