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