google-cloud-retail-v2 0.14.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/google/cloud/retail/v2/catalog_service/client.rb +2 -2
  4. data/lib/google/cloud/retail/v2/catalog_service/rest/client.rb +2 -2
  5. data/lib/google/cloud/retail/v2/common_pb.rb +6 -0
  6. data/lib/google/cloud/retail/v2/completion_service/client.rb +11 -4
  7. data/lib/google/cloud/retail/v2/completion_service/operations.rb +2 -2
  8. data/lib/google/cloud/retail/v2/completion_service/rest/client.rb +11 -4
  9. data/lib/google/cloud/retail/v2/completion_service/rest/operations.rb +2 -2
  10. data/lib/google/cloud/retail/v2/completion_service/rest.rb +1 -1
  11. data/lib/google/cloud/retail/v2/completion_service.rb +1 -1
  12. data/lib/google/cloud/retail/v2/completion_service_pb.rb +1 -0
  13. data/lib/google/cloud/retail/v2/completion_service_services_pb.rb +1 -1
  14. data/lib/google/cloud/retail/v2/control_service/client.rb +2 -2
  15. data/lib/google/cloud/retail/v2/control_service/rest/client.rb +2 -2
  16. data/lib/google/cloud/retail/v2/model_pb.rb +70 -0
  17. data/lib/google/cloud/retail/v2/model_service/client.rb +1126 -0
  18. data/lib/google/cloud/retail/v2/model_service/credentials.rb +51 -0
  19. data/lib/google/cloud/retail/v2/model_service/operations.rb +768 -0
  20. data/lib/google/cloud/retail/v2/model_service/paths.rb +73 -0
  21. data/lib/google/cloud/retail/v2/model_service/rest/client.rb +904 -0
  22. data/lib/google/cloud/retail/v2/model_service/rest/operations.rb +828 -0
  23. data/lib/google/cloud/retail/v2/model_service/rest/service_stub.rb +525 -0
  24. data/lib/google/cloud/retail/v2/model_service/rest.rb +64 -0
  25. data/lib/google/cloud/retail/v2/model_service.rb +67 -0
  26. data/lib/google/cloud/retail/v2/model_service_pb.rb +80 -0
  27. data/lib/google/cloud/retail/v2/model_service_services_pb.rb +73 -0
  28. data/lib/google/cloud/retail/v2/prediction_service/client.rb +5 -2
  29. data/lib/google/cloud/retail/v2/prediction_service/rest/client.rb +5 -2
  30. data/lib/google/cloud/retail/v2/product_service/client.rb +18 -17
  31. data/lib/google/cloud/retail/v2/product_service/operations.rb +2 -2
  32. data/lib/google/cloud/retail/v2/product_service/rest/client.rb +18 -17
  33. data/lib/google/cloud/retail/v2/product_service/rest/operations.rb +2 -2
  34. data/lib/google/cloud/retail/v2/product_service_services_pb.rb +16 -15
  35. data/lib/google/cloud/retail/v2/rest.rb +1 -0
  36. data/lib/google/cloud/retail/v2/search_service/client.rb +11 -4
  37. data/lib/google/cloud/retail/v2/search_service/rest/client.rb +11 -4
  38. data/lib/google/cloud/retail/v2/search_service_pb.rb +14 -0
  39. data/lib/google/cloud/retail/v2/serving_config_service/client.rb +2 -2
  40. data/lib/google/cloud/retail/v2/serving_config_service/rest/client.rb +2 -2
  41. data/lib/google/cloud/retail/v2/user_event_pb.rb +1 -0
  42. data/lib/google/cloud/retail/v2/user_event_service/client.rb +3 -3
  43. data/lib/google/cloud/retail/v2/user_event_service/operations.rb +2 -2
  44. data/lib/google/cloud/retail/v2/user_event_service/rest/client.rb +3 -3
  45. data/lib/google/cloud/retail/v2/user_event_service/rest/operations.rb +2 -2
  46. data/lib/google/cloud/retail/v2/version.rb +1 -1
  47. data/lib/google/cloud/retail/v2.rb +1 -0
  48. data/proto_docs/google/api/client.rb +57 -3
  49. data/proto_docs/google/cloud/retail/v2/catalog.rb +11 -6
  50. data/proto_docs/google/cloud/retail/v2/common.rb +15 -1
  51. data/proto_docs/google/cloud/retail/v2/completion_service.rb +10 -2
  52. data/proto_docs/google/cloud/retail/v2/import_config.rb +1 -1
  53. data/proto_docs/google/cloud/retail/v2/model.rb +228 -0
  54. data/proto_docs/google/cloud/retail/v2/model_service.rb +172 -0
  55. data/proto_docs/google/cloud/retail/v2/prediction_service.rb +3 -0
  56. data/proto_docs/google/cloud/retail/v2/product.rb +2 -3
  57. data/proto_docs/google/cloud/retail/v2/search_service.rb +56 -2
  58. data/proto_docs/google/cloud/retail/v2/serving_config.rb +3 -3
  59. data/proto_docs/google/cloud/retail/v2/user_event.rb +7 -0
  60. data/proto_docs/google/cloud/retail/v2/user_event_service.rb +1 -1
  61. metadata +16 -2
@@ -0,0 +1,904 @@
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/model_service_pb"
21
+ require "google/cloud/retail/v2/model_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 ModelService
29
+ module Rest
30
+ ##
31
+ # REST client for the ModelService service.
32
+ #
33
+ # Service for performing CRUD operations on models.
34
+ # Recommendation models contain all the metadata necessary to generate a set of
35
+ # models for the `Predict()` API. A model is queried
36
+ # indirectly via a ServingConfig, which associates a model with a
37
+ # given Placement (e.g. Frequently Bought Together on Home Page).
38
+ #
39
+ # This service allows you to do the following:
40
+ #
41
+ # * Initiate training of a model.
42
+ # * Pause training of an existing model.
43
+ # * List all the available models along with their metadata.
44
+ # * Control their tuning schedule.
45
+ #
46
+ class Client
47
+ include Paths
48
+
49
+ # @private
50
+ attr_reader :model_service_stub
51
+
52
+ ##
53
+ # Configure the ModelService Client class.
54
+ #
55
+ # See {::Google::Cloud::Retail::V2::ModelService::Rest::Client::Configuration}
56
+ # for a description of the configuration fields.
57
+ #
58
+ # @example
59
+ #
60
+ # # Modify the configuration for all ModelService clients
61
+ # ::Google::Cloud::Retail::V2::ModelService::Rest::Client.configure do |config|
62
+ # config.timeout = 10.0
63
+ # end
64
+ #
65
+ # @yield [config] Configure the Client client.
66
+ # @yieldparam config [Client::Configuration]
67
+ #
68
+ # @return [Client::Configuration]
69
+ #
70
+ def self.configure
71
+ @configure ||= begin
72
+ namespace = ["Google", "Cloud", "Retail", "V2"]
73
+ parent_config = while namespace.any?
74
+ parent_name = namespace.join "::"
75
+ parent_const = const_get parent_name
76
+ break parent_const.configure if parent_const.respond_to? :configure
77
+ namespace.pop
78
+ end
79
+ default_config = Client::Configuration.new parent_config
80
+
81
+ default_config.timeout = 60.0
82
+ default_config.retry_policy = {
83
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
84
+ }
85
+
86
+ default_config
87
+ end
88
+ yield @configure if block_given?
89
+ @configure
90
+ end
91
+
92
+ ##
93
+ # Configure the ModelService Client instance.
94
+ #
95
+ # The configuration is set to the derived mode, meaning that values can be changed,
96
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
97
+ # should be made on {Client.configure}.
98
+ #
99
+ # See {::Google::Cloud::Retail::V2::ModelService::Rest::Client::Configuration}
100
+ # for a description of the configuration fields.
101
+ #
102
+ # @yield [config] Configure the Client client.
103
+ # @yieldparam config [Client::Configuration]
104
+ #
105
+ # @return [Client::Configuration]
106
+ #
107
+ def configure
108
+ yield @config if block_given?
109
+ @config
110
+ end
111
+
112
+ ##
113
+ # Create a new ModelService REST client object.
114
+ #
115
+ # @example
116
+ #
117
+ # # Create a client using the default configuration
118
+ # client = ::Google::Cloud::Retail::V2::ModelService::Rest::Client.new
119
+ #
120
+ # # Create a client using a custom configuration
121
+ # client = ::Google::Cloud::Retail::V2::ModelService::Rest::Client.new do |config|
122
+ # config.timeout = 10.0
123
+ # end
124
+ #
125
+ # @yield [config] Configure the ModelService client.
126
+ # @yieldparam config [Client::Configuration]
127
+ #
128
+ def initialize
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
+ # Use self-signed JWT if the endpoint is unchanged from default,
138
+ # but only if the default endpoint does not have a region prefix.
139
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
140
+ !@config.endpoint.split(".").first.include?("-")
141
+ credentials ||= Credentials.default scope: @config.scope,
142
+ enable_self_signed_jwt: enable_self_signed_jwt
143
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
144
+ credentials = Credentials.new credentials, scope: @config.scope
145
+ end
146
+
147
+ @quota_project_id = @config.quota_project
148
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
149
+
150
+ @operations_client = ::Google::Cloud::Retail::V2::ModelService::Rest::Operations.new do |config|
151
+ config.credentials = credentials
152
+ config.quota_project = @quota_project_id
153
+ config.endpoint = @config.endpoint
154
+ end
155
+
156
+ @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
157
+ config.credentials = credentials
158
+ config.quota_project = @quota_project_id
159
+ config.endpoint = @config.endpoint
160
+ end
161
+
162
+ @model_service_stub = ::Google::Cloud::Retail::V2::ModelService::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
163
+ end
164
+
165
+ ##
166
+ # Get the associated client for long-running operations.
167
+ #
168
+ # @return [::Google::Cloud::Retail::V2::ModelService::Rest::Operations]
169
+ #
170
+ attr_reader :operations_client
171
+
172
+ ##
173
+ # Get the associated client for mix-in of the Locations.
174
+ #
175
+ # @return [Google::Cloud::Location::Locations::Rest::Client]
176
+ #
177
+ attr_reader :location_client
178
+
179
+ # Service calls
180
+
181
+ ##
182
+ # Creates a new model.
183
+ #
184
+ # @overload create_model(request, options = nil)
185
+ # Pass arguments to `create_model` via a request object, either of type
186
+ # {::Google::Cloud::Retail::V2::CreateModelRequest} or an equivalent Hash.
187
+ #
188
+ # @param request [::Google::Cloud::Retail::V2::CreateModelRequest, ::Hash]
189
+ # A request object representing the call parameters. Required. To specify no
190
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
191
+ # @param options [::Gapic::CallOptions, ::Hash]
192
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
193
+ #
194
+ # @overload create_model(parent: nil, model: nil, dry_run: nil)
195
+ # Pass arguments to `create_model` via keyword arguments. Note that at
196
+ # least one keyword argument is required. To specify no parameters, or to keep all
197
+ # the default parameter values, pass an empty Hash as a request object (see above).
198
+ #
199
+ # @param parent [::String]
200
+ # Required. The parent resource under which to create the model. Format:
201
+ # `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}`
202
+ # @param model [::Google::Cloud::Retail::V2::Model, ::Hash]
203
+ # Required. The payload of the {::Google::Cloud::Retail::V2::Model Model} to
204
+ # create.
205
+ # @param dry_run [::Boolean]
206
+ # Optional. Whether to run a dry run to validate the request (without
207
+ # actually creating the model).
208
+ # @yield [result, operation] Access the result along with the TransportOperation object
209
+ # @yieldparam result [::Gapic::Operation]
210
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
211
+ #
212
+ # @return [::Gapic::Operation]
213
+ #
214
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
215
+ def create_model request, options = nil
216
+ raise ::ArgumentError, "request must be provided" if request.nil?
217
+
218
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::CreateModelRequest
219
+
220
+ # Converts hash and nil to an options object
221
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
222
+
223
+ # Customize the options with defaults
224
+ call_metadata = @config.rpcs.create_model.metadata.to_h
225
+
226
+ # Set x-goog-api-client and x-goog-user-project headers
227
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
228
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
229
+ gapic_version: ::Google::Cloud::Retail::V2::VERSION,
230
+ transports_version_send: [:rest]
231
+
232
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
233
+
234
+ options.apply_defaults timeout: @config.rpcs.create_model.timeout,
235
+ metadata: call_metadata,
236
+ retry_policy: @config.rpcs.create_model.retry_policy
237
+
238
+ options.apply_defaults timeout: @config.timeout,
239
+ metadata: @config.metadata,
240
+ retry_policy: @config.retry_policy
241
+
242
+ @model_service_stub.create_model request, options do |result, operation|
243
+ result = ::Gapic::Operation.new result, @operations_client, options: options
244
+ yield result, operation if block_given?
245
+ return result
246
+ end
247
+ rescue ::Gapic::Rest::Error => e
248
+ raise ::Google::Cloud::Error.from_error(e)
249
+ end
250
+
251
+ ##
252
+ # Gets a model.
253
+ #
254
+ # @overload get_model(request, options = nil)
255
+ # Pass arguments to `get_model` via a request object, either of type
256
+ # {::Google::Cloud::Retail::V2::GetModelRequest} or an equivalent Hash.
257
+ #
258
+ # @param request [::Google::Cloud::Retail::V2::GetModelRequest, ::Hash]
259
+ # A request object representing the call parameters. Required. To specify no
260
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
261
+ # @param options [::Gapic::CallOptions, ::Hash]
262
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
263
+ #
264
+ # @overload get_model(name: nil)
265
+ # Pass arguments to `get_model` via keyword arguments. Note that at
266
+ # least one keyword argument is required. To specify no parameters, or to keep all
267
+ # the default parameter values, pass an empty Hash as a request object (see above).
268
+ #
269
+ # @param name [::String]
270
+ # Required. The resource name of the {::Google::Cloud::Retail::V2::Model Model} to
271
+ # get. Format:
272
+ # `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_id}`
273
+ # @yield [result, operation] Access the result along with the TransportOperation object
274
+ # @yieldparam result [::Google::Cloud::Retail::V2::Model]
275
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
276
+ #
277
+ # @return [::Google::Cloud::Retail::V2::Model]
278
+ #
279
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
280
+ def get_model request, options = nil
281
+ raise ::ArgumentError, "request must be provided" if request.nil?
282
+
283
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::GetModelRequest
284
+
285
+ # Converts hash and nil to an options object
286
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
287
+
288
+ # Customize the options with defaults
289
+ call_metadata = @config.rpcs.get_model.metadata.to_h
290
+
291
+ # Set x-goog-api-client and x-goog-user-project headers
292
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
293
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
294
+ gapic_version: ::Google::Cloud::Retail::V2::VERSION,
295
+ transports_version_send: [:rest]
296
+
297
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
298
+
299
+ options.apply_defaults timeout: @config.rpcs.get_model.timeout,
300
+ metadata: call_metadata,
301
+ retry_policy: @config.rpcs.get_model.retry_policy
302
+
303
+ options.apply_defaults timeout: @config.timeout,
304
+ metadata: @config.metadata,
305
+ retry_policy: @config.retry_policy
306
+
307
+ @model_service_stub.get_model request, options do |result, operation|
308
+ yield result, operation if block_given?
309
+ return result
310
+ end
311
+ rescue ::Gapic::Rest::Error => e
312
+ raise ::Google::Cloud::Error.from_error(e)
313
+ end
314
+
315
+ ##
316
+ # Pauses the training of an existing model.
317
+ #
318
+ # @overload pause_model(request, options = nil)
319
+ # Pass arguments to `pause_model` via a request object, either of type
320
+ # {::Google::Cloud::Retail::V2::PauseModelRequest} or an equivalent Hash.
321
+ #
322
+ # @param request [::Google::Cloud::Retail::V2::PauseModelRequest, ::Hash]
323
+ # A request object representing the call parameters. Required. To specify no
324
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
325
+ # @param options [::Gapic::CallOptions, ::Hash]
326
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
327
+ #
328
+ # @overload pause_model(name: nil)
329
+ # Pass arguments to `pause_model` via keyword arguments. Note that at
330
+ # least one keyword argument is required. To specify no parameters, or to keep all
331
+ # the default parameter values, pass an empty Hash as a request object (see above).
332
+ #
333
+ # @param name [::String]
334
+ # Required. The name of the model to pause.
335
+ # Format:
336
+ # `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}`
337
+ # @yield [result, operation] Access the result along with the TransportOperation object
338
+ # @yieldparam result [::Google::Cloud::Retail::V2::Model]
339
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
340
+ #
341
+ # @return [::Google::Cloud::Retail::V2::Model]
342
+ #
343
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
344
+ def pause_model request, options = nil
345
+ raise ::ArgumentError, "request must be provided" if request.nil?
346
+
347
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::PauseModelRequest
348
+
349
+ # Converts hash and nil to an options object
350
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
351
+
352
+ # Customize the options with defaults
353
+ call_metadata = @config.rpcs.pause_model.metadata.to_h
354
+
355
+ # Set x-goog-api-client and x-goog-user-project headers
356
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
357
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
358
+ gapic_version: ::Google::Cloud::Retail::V2::VERSION,
359
+ transports_version_send: [:rest]
360
+
361
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
362
+
363
+ options.apply_defaults timeout: @config.rpcs.pause_model.timeout,
364
+ metadata: call_metadata,
365
+ retry_policy: @config.rpcs.pause_model.retry_policy
366
+
367
+ options.apply_defaults timeout: @config.timeout,
368
+ metadata: @config.metadata,
369
+ retry_policy: @config.retry_policy
370
+
371
+ @model_service_stub.pause_model request, options do |result, operation|
372
+ yield result, operation if block_given?
373
+ return result
374
+ end
375
+ rescue ::Gapic::Rest::Error => e
376
+ raise ::Google::Cloud::Error.from_error(e)
377
+ end
378
+
379
+ ##
380
+ # Resumes the training of an existing model.
381
+ #
382
+ # @overload resume_model(request, options = nil)
383
+ # Pass arguments to `resume_model` via a request object, either of type
384
+ # {::Google::Cloud::Retail::V2::ResumeModelRequest} or an equivalent Hash.
385
+ #
386
+ # @param request [::Google::Cloud::Retail::V2::ResumeModelRequest, ::Hash]
387
+ # A request object representing the call parameters. Required. To specify no
388
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
389
+ # @param options [::Gapic::CallOptions, ::Hash]
390
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
391
+ #
392
+ # @overload resume_model(name: nil)
393
+ # Pass arguments to `resume_model` via keyword arguments. Note that at
394
+ # least one keyword argument is required. To specify no parameters, or to keep all
395
+ # the default parameter values, pass an empty Hash as a request object (see above).
396
+ #
397
+ # @param name [::String]
398
+ # Required. The name of the model to resume.
399
+ # Format:
400
+ # `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}`
401
+ # @yield [result, operation] Access the result along with the TransportOperation object
402
+ # @yieldparam result [::Google::Cloud::Retail::V2::Model]
403
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
404
+ #
405
+ # @return [::Google::Cloud::Retail::V2::Model]
406
+ #
407
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
408
+ def resume_model request, options = nil
409
+ raise ::ArgumentError, "request must be provided" if request.nil?
410
+
411
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::ResumeModelRequest
412
+
413
+ # Converts hash and nil to an options object
414
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
415
+
416
+ # Customize the options with defaults
417
+ call_metadata = @config.rpcs.resume_model.metadata.to_h
418
+
419
+ # Set x-goog-api-client and x-goog-user-project headers
420
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
421
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
422
+ gapic_version: ::Google::Cloud::Retail::V2::VERSION,
423
+ transports_version_send: [:rest]
424
+
425
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
426
+
427
+ options.apply_defaults timeout: @config.rpcs.resume_model.timeout,
428
+ metadata: call_metadata,
429
+ retry_policy: @config.rpcs.resume_model.retry_policy
430
+
431
+ options.apply_defaults timeout: @config.timeout,
432
+ metadata: @config.metadata,
433
+ retry_policy: @config.retry_policy
434
+
435
+ @model_service_stub.resume_model request, options do |result, operation|
436
+ yield result, operation if block_given?
437
+ return result
438
+ end
439
+ rescue ::Gapic::Rest::Error => e
440
+ raise ::Google::Cloud::Error.from_error(e)
441
+ end
442
+
443
+ ##
444
+ # Deletes an existing model.
445
+ #
446
+ # @overload delete_model(request, options = nil)
447
+ # Pass arguments to `delete_model` via a request object, either of type
448
+ # {::Google::Cloud::Retail::V2::DeleteModelRequest} or an equivalent Hash.
449
+ #
450
+ # @param request [::Google::Cloud::Retail::V2::DeleteModelRequest, ::Hash]
451
+ # A request object representing the call parameters. Required. To specify no
452
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
453
+ # @param options [::Gapic::CallOptions, ::Hash]
454
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
455
+ #
456
+ # @overload delete_model(name: nil)
457
+ # Pass arguments to `delete_model` via keyword arguments. Note that at
458
+ # least one keyword argument is required. To specify no parameters, or to keep all
459
+ # the default parameter values, pass an empty Hash as a request object (see above).
460
+ #
461
+ # @param name [::String]
462
+ # Required. The resource name of the {::Google::Cloud::Retail::V2::Model Model} to
463
+ # delete. Format:
464
+ # `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}`
465
+ # @yield [result, operation] Access the result along with the TransportOperation object
466
+ # @yieldparam result [::Google::Protobuf::Empty]
467
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
468
+ #
469
+ # @return [::Google::Protobuf::Empty]
470
+ #
471
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
472
+ def delete_model request, options = nil
473
+ raise ::ArgumentError, "request must be provided" if request.nil?
474
+
475
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::DeleteModelRequest
476
+
477
+ # Converts hash and nil to an options object
478
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
479
+
480
+ # Customize the options with defaults
481
+ call_metadata = @config.rpcs.delete_model.metadata.to_h
482
+
483
+ # Set x-goog-api-client and x-goog-user-project headers
484
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
485
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
486
+ gapic_version: ::Google::Cloud::Retail::V2::VERSION,
487
+ transports_version_send: [:rest]
488
+
489
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
490
+
491
+ options.apply_defaults timeout: @config.rpcs.delete_model.timeout,
492
+ metadata: call_metadata,
493
+ retry_policy: @config.rpcs.delete_model.retry_policy
494
+
495
+ options.apply_defaults timeout: @config.timeout,
496
+ metadata: @config.metadata,
497
+ retry_policy: @config.retry_policy
498
+
499
+ @model_service_stub.delete_model request, options do |result, operation|
500
+ yield result, operation if block_given?
501
+ return result
502
+ end
503
+ rescue ::Gapic::Rest::Error => e
504
+ raise ::Google::Cloud::Error.from_error(e)
505
+ end
506
+
507
+ ##
508
+ # Lists all the models linked to this event store.
509
+ #
510
+ # @overload list_models(request, options = nil)
511
+ # Pass arguments to `list_models` via a request object, either of type
512
+ # {::Google::Cloud::Retail::V2::ListModelsRequest} or an equivalent Hash.
513
+ #
514
+ # @param request [::Google::Cloud::Retail::V2::ListModelsRequest, ::Hash]
515
+ # A request object representing the call parameters. Required. To specify no
516
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
517
+ # @param options [::Gapic::CallOptions, ::Hash]
518
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
519
+ #
520
+ # @overload list_models(parent: nil, page_size: nil, page_token: nil)
521
+ # Pass arguments to `list_models` via keyword arguments. Note that at
522
+ # least one keyword argument is required. To specify no parameters, or to keep all
523
+ # the default parameter values, pass an empty Hash as a request object (see above).
524
+ #
525
+ # @param parent [::String]
526
+ # Required. The parent for which to list models.
527
+ # Format:
528
+ # `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}`
529
+ # @param page_size [::Integer]
530
+ # Optional. Maximum number of results to return. If unspecified, defaults
531
+ # to 50. Max allowed value is 1000.
532
+ # @param page_token [::String]
533
+ # Optional. A page token, received from a previous `ListModels`
534
+ # call. Provide this to retrieve the subsequent page.
535
+ # @yield [result, operation] Access the result along with the TransportOperation object
536
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Retail::V2::Model>]
537
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
538
+ #
539
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Retail::V2::Model>]
540
+ #
541
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
542
+ def list_models request, options = nil
543
+ raise ::ArgumentError, "request must be provided" if request.nil?
544
+
545
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::ListModelsRequest
546
+
547
+ # Converts hash and nil to an options object
548
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
549
+
550
+ # Customize the options with defaults
551
+ call_metadata = @config.rpcs.list_models.metadata.to_h
552
+
553
+ # Set x-goog-api-client and x-goog-user-project headers
554
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
555
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
556
+ gapic_version: ::Google::Cloud::Retail::V2::VERSION,
557
+ transports_version_send: [:rest]
558
+
559
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
560
+
561
+ options.apply_defaults timeout: @config.rpcs.list_models.timeout,
562
+ metadata: call_metadata,
563
+ retry_policy: @config.rpcs.list_models.retry_policy
564
+
565
+ options.apply_defaults timeout: @config.timeout,
566
+ metadata: @config.metadata,
567
+ retry_policy: @config.retry_policy
568
+
569
+ @model_service_stub.list_models request, options do |result, operation|
570
+ result = ::Gapic::Rest::PagedEnumerable.new @model_service_stub, :list_models, "models", request, result, options
571
+ yield result, operation if block_given?
572
+ return result
573
+ end
574
+ rescue ::Gapic::Rest::Error => e
575
+ raise ::Google::Cloud::Error.from_error(e)
576
+ end
577
+
578
+ ##
579
+ # Update of model metadata. Only fields that
580
+ # currently can be updated are: `filtering_option` and
581
+ # `periodic_tuning_state`.
582
+ # If other values are provided, this API method ignores them.
583
+ #
584
+ # @overload update_model(request, options = nil)
585
+ # Pass arguments to `update_model` via a request object, either of type
586
+ # {::Google::Cloud::Retail::V2::UpdateModelRequest} or an equivalent Hash.
587
+ #
588
+ # @param request [::Google::Cloud::Retail::V2::UpdateModelRequest, ::Hash]
589
+ # A request object representing the call parameters. Required. To specify no
590
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
591
+ # @param options [::Gapic::CallOptions, ::Hash]
592
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
593
+ #
594
+ # @overload update_model(model: nil, update_mask: nil)
595
+ # Pass arguments to `update_model` via keyword arguments. Note that at
596
+ # least one keyword argument is required. To specify no parameters, or to keep all
597
+ # the default parameter values, pass an empty Hash as a request object (see above).
598
+ #
599
+ # @param model [::Google::Cloud::Retail::V2::Model, ::Hash]
600
+ # Required. The body of the updated {::Google::Cloud::Retail::V2::Model Model}.
601
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
602
+ # Optional. Indicates which fields in the provided 'model' to
603
+ # update. If not set, by default updates all fields.
604
+ # @yield [result, operation] Access the result along with the TransportOperation object
605
+ # @yieldparam result [::Google::Cloud::Retail::V2::Model]
606
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
607
+ #
608
+ # @return [::Google::Cloud::Retail::V2::Model]
609
+ #
610
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
611
+ def update_model request, options = nil
612
+ raise ::ArgumentError, "request must be provided" if request.nil?
613
+
614
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::UpdateModelRequest
615
+
616
+ # Converts hash and nil to an options object
617
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
618
+
619
+ # Customize the options with defaults
620
+ call_metadata = @config.rpcs.update_model.metadata.to_h
621
+
622
+ # Set x-goog-api-client and x-goog-user-project headers
623
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
624
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
625
+ gapic_version: ::Google::Cloud::Retail::V2::VERSION,
626
+ transports_version_send: [:rest]
627
+
628
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
629
+
630
+ options.apply_defaults timeout: @config.rpcs.update_model.timeout,
631
+ metadata: call_metadata,
632
+ retry_policy: @config.rpcs.update_model.retry_policy
633
+
634
+ options.apply_defaults timeout: @config.timeout,
635
+ metadata: @config.metadata,
636
+ retry_policy: @config.retry_policy
637
+
638
+ @model_service_stub.update_model request, options do |result, operation|
639
+ yield result, operation if block_given?
640
+ return result
641
+ end
642
+ rescue ::Gapic::Rest::Error => e
643
+ raise ::Google::Cloud::Error.from_error(e)
644
+ end
645
+
646
+ ##
647
+ # Tunes an existing model.
648
+ #
649
+ # @overload tune_model(request, options = nil)
650
+ # Pass arguments to `tune_model` via a request object, either of type
651
+ # {::Google::Cloud::Retail::V2::TuneModelRequest} or an equivalent Hash.
652
+ #
653
+ # @param request [::Google::Cloud::Retail::V2::TuneModelRequest, ::Hash]
654
+ # A request object representing the call parameters. Required. To specify no
655
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
656
+ # @param options [::Gapic::CallOptions, ::Hash]
657
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
658
+ #
659
+ # @overload tune_model(name: nil)
660
+ # Pass arguments to `tune_model` via keyword arguments. Note that at
661
+ # least one keyword argument is required. To specify no parameters, or to keep all
662
+ # the default parameter values, pass an empty Hash as a request object (see above).
663
+ #
664
+ # @param name [::String]
665
+ # Required. The resource name of the model to tune.
666
+ # Format:
667
+ # `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}`
668
+ # @yield [result, operation] Access the result along with the TransportOperation object
669
+ # @yieldparam result [::Gapic::Operation]
670
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
671
+ #
672
+ # @return [::Gapic::Operation]
673
+ #
674
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
675
+ def tune_model request, options = nil
676
+ raise ::ArgumentError, "request must be provided" if request.nil?
677
+
678
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::TuneModelRequest
679
+
680
+ # Converts hash and nil to an options object
681
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
682
+
683
+ # Customize the options with defaults
684
+ call_metadata = @config.rpcs.tune_model.metadata.to_h
685
+
686
+ # Set x-goog-api-client and x-goog-user-project headers
687
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
688
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
689
+ gapic_version: ::Google::Cloud::Retail::V2::VERSION,
690
+ transports_version_send: [:rest]
691
+
692
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
693
+
694
+ options.apply_defaults timeout: @config.rpcs.tune_model.timeout,
695
+ metadata: call_metadata,
696
+ retry_policy: @config.rpcs.tune_model.retry_policy
697
+
698
+ options.apply_defaults timeout: @config.timeout,
699
+ metadata: @config.metadata,
700
+ retry_policy: @config.retry_policy
701
+
702
+ @model_service_stub.tune_model request, options do |result, operation|
703
+ result = ::Gapic::Operation.new result, @operations_client, options: options
704
+ yield result, operation if block_given?
705
+ return result
706
+ end
707
+ rescue ::Gapic::Rest::Error => e
708
+ raise ::Google::Cloud::Error.from_error(e)
709
+ end
710
+
711
+ ##
712
+ # Configuration class for the ModelService REST API.
713
+ #
714
+ # This class represents the configuration for ModelService REST,
715
+ # providing control over timeouts, retry behavior, logging, transport
716
+ # parameters, and other low-level controls. Certain parameters can also be
717
+ # applied individually to specific RPCs. See
718
+ # {::Google::Cloud::Retail::V2::ModelService::Rest::Client::Configuration::Rpcs}
719
+ # for a list of RPCs that can be configured independently.
720
+ #
721
+ # Configuration can be applied globally to all clients, or to a single client
722
+ # on construction.
723
+ #
724
+ # @example
725
+ #
726
+ # # Modify the global config, setting the timeout for
727
+ # # create_model to 20 seconds,
728
+ # # and all remaining timeouts to 10 seconds.
729
+ # ::Google::Cloud::Retail::V2::ModelService::Rest::Client.configure do |config|
730
+ # config.timeout = 10.0
731
+ # config.rpcs.create_model.timeout = 20.0
732
+ # end
733
+ #
734
+ # # Apply the above configuration only to a new client.
735
+ # client = ::Google::Cloud::Retail::V2::ModelService::Rest::Client.new do |config|
736
+ # config.timeout = 10.0
737
+ # config.rpcs.create_model.timeout = 20.0
738
+ # end
739
+ #
740
+ # @!attribute [rw] endpoint
741
+ # The hostname or hostname:port of the service endpoint.
742
+ # Defaults to `"retail.googleapis.com"`.
743
+ # @return [::String]
744
+ # @!attribute [rw] credentials
745
+ # Credentials to send with calls. You may provide any of the following types:
746
+ # * (`String`) The path to a service account key file in JSON format
747
+ # * (`Hash`) A service account key as a Hash
748
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
749
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
750
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
751
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
752
+ # * (`nil`) indicating no credentials
753
+ # @return [::Object]
754
+ # @!attribute [rw] scope
755
+ # The OAuth scopes
756
+ # @return [::Array<::String>]
757
+ # @!attribute [rw] lib_name
758
+ # The library name as recorded in instrumentation and logging
759
+ # @return [::String]
760
+ # @!attribute [rw] lib_version
761
+ # The library version as recorded in instrumentation and logging
762
+ # @return [::String]
763
+ # @!attribute [rw] timeout
764
+ # The call timeout in seconds.
765
+ # @return [::Numeric]
766
+ # @!attribute [rw] metadata
767
+ # Additional headers to be sent with the call.
768
+ # @return [::Hash{::Symbol=>::String}]
769
+ # @!attribute [rw] retry_policy
770
+ # The retry policy. The value is a hash with the following keys:
771
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
772
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
773
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
774
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
775
+ # trigger a retry.
776
+ # @return [::Hash]
777
+ # @!attribute [rw] quota_project
778
+ # A separate project against which to charge quota.
779
+ # @return [::String]
780
+ #
781
+ class Configuration
782
+ extend ::Gapic::Config
783
+
784
+ config_attr :endpoint, "retail.googleapis.com", ::String
785
+ config_attr :credentials, nil do |value|
786
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
787
+ allowed.any? { |klass| klass === value }
788
+ end
789
+ config_attr :scope, nil, ::String, ::Array, nil
790
+ config_attr :lib_name, nil, ::String, nil
791
+ config_attr :lib_version, nil, ::String, nil
792
+ config_attr :timeout, nil, ::Numeric, nil
793
+ config_attr :metadata, nil, ::Hash, nil
794
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
795
+ config_attr :quota_project, nil, ::String, nil
796
+
797
+ # @private
798
+ def initialize parent_config = nil
799
+ @parent_config = parent_config unless parent_config.nil?
800
+
801
+ yield self if block_given?
802
+ end
803
+
804
+ ##
805
+ # Configurations for individual RPCs
806
+ # @return [Rpcs]
807
+ #
808
+ def rpcs
809
+ @rpcs ||= begin
810
+ parent_rpcs = nil
811
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
812
+ Rpcs.new parent_rpcs
813
+ end
814
+ end
815
+
816
+ ##
817
+ # Configuration RPC class for the ModelService API.
818
+ #
819
+ # Includes fields providing the configuration for each RPC in this service.
820
+ # Each configuration object is of type `Gapic::Config::Method` and includes
821
+ # the following configuration fields:
822
+ #
823
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
824
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
825
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
826
+ # include the following keys:
827
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
828
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
829
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
830
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
831
+ # trigger a retry.
832
+ #
833
+ class Rpcs
834
+ ##
835
+ # RPC-specific configuration for `create_model`
836
+ # @return [::Gapic::Config::Method]
837
+ #
838
+ attr_reader :create_model
839
+ ##
840
+ # RPC-specific configuration for `get_model`
841
+ # @return [::Gapic::Config::Method]
842
+ #
843
+ attr_reader :get_model
844
+ ##
845
+ # RPC-specific configuration for `pause_model`
846
+ # @return [::Gapic::Config::Method]
847
+ #
848
+ attr_reader :pause_model
849
+ ##
850
+ # RPC-specific configuration for `resume_model`
851
+ # @return [::Gapic::Config::Method]
852
+ #
853
+ attr_reader :resume_model
854
+ ##
855
+ # RPC-specific configuration for `delete_model`
856
+ # @return [::Gapic::Config::Method]
857
+ #
858
+ attr_reader :delete_model
859
+ ##
860
+ # RPC-specific configuration for `list_models`
861
+ # @return [::Gapic::Config::Method]
862
+ #
863
+ attr_reader :list_models
864
+ ##
865
+ # RPC-specific configuration for `update_model`
866
+ # @return [::Gapic::Config::Method]
867
+ #
868
+ attr_reader :update_model
869
+ ##
870
+ # RPC-specific configuration for `tune_model`
871
+ # @return [::Gapic::Config::Method]
872
+ #
873
+ attr_reader :tune_model
874
+
875
+ # @private
876
+ def initialize parent_rpcs = nil
877
+ create_model_config = parent_rpcs.create_model if parent_rpcs.respond_to? :create_model
878
+ @create_model = ::Gapic::Config::Method.new create_model_config
879
+ get_model_config = parent_rpcs.get_model if parent_rpcs.respond_to? :get_model
880
+ @get_model = ::Gapic::Config::Method.new get_model_config
881
+ pause_model_config = parent_rpcs.pause_model if parent_rpcs.respond_to? :pause_model
882
+ @pause_model = ::Gapic::Config::Method.new pause_model_config
883
+ resume_model_config = parent_rpcs.resume_model if parent_rpcs.respond_to? :resume_model
884
+ @resume_model = ::Gapic::Config::Method.new resume_model_config
885
+ delete_model_config = parent_rpcs.delete_model if parent_rpcs.respond_to? :delete_model
886
+ @delete_model = ::Gapic::Config::Method.new delete_model_config
887
+ list_models_config = parent_rpcs.list_models if parent_rpcs.respond_to? :list_models
888
+ @list_models = ::Gapic::Config::Method.new list_models_config
889
+ update_model_config = parent_rpcs.update_model if parent_rpcs.respond_to? :update_model
890
+ @update_model = ::Gapic::Config::Method.new update_model_config
891
+ tune_model_config = parent_rpcs.tune_model if parent_rpcs.respond_to? :tune_model
892
+ @tune_model = ::Gapic::Config::Method.new tune_model_config
893
+
894
+ yield self if block_given?
895
+ end
896
+ end
897
+ end
898
+ end
899
+ end
900
+ end
901
+ end
902
+ end
903
+ end
904
+ end