google-cloud-retail-v2 0.13.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/google/cloud/retail/v2/catalog_service/rest/client.rb +1220 -0
  4. data/lib/google/cloud/retail/v2/catalog_service/rest/service_stub.rb +704 -0
  5. data/lib/google/cloud/retail/v2/catalog_service/rest.rb +52 -0
  6. data/lib/google/cloud/retail/v2/catalog_service.rb +6 -0
  7. data/lib/google/cloud/retail/v2/completion_service/rest/client.rb +533 -0
  8. data/lib/google/cloud/retail/v2/completion_service/rest/operations.rb +828 -0
  9. data/lib/google/cloud/retail/v2/completion_service/rest/service_stub.rb +167 -0
  10. data/lib/google/cloud/retail/v2/completion_service/rest.rb +56 -0
  11. data/lib/google/cloud/retail/v2/completion_service.rb +6 -0
  12. data/lib/google/cloud/retail/v2/control_service/rest/client.rb +680 -0
  13. data/lib/google/cloud/retail/v2/control_service/rest/service_stub.rb +345 -0
  14. data/lib/google/cloud/retail/v2/control_service/rest.rb +52 -0
  15. data/lib/google/cloud/retail/v2/control_service.rb +6 -0
  16. data/lib/google/cloud/retail/v2/prediction_service/rest/client.rb +486 -0
  17. data/lib/google/cloud/retail/v2/prediction_service/rest/service_stub.rb +116 -0
  18. data/lib/google/cloud/retail/v2/prediction_service/rest.rb +52 -0
  19. data/lib/google/cloud/retail/v2/prediction_service.rb +6 -0
  20. data/lib/google/cloud/retail/v2/product_service/rest/client.rb +1649 -0
  21. data/lib/google/cloud/retail/v2/product_service/rest/operations.rb +828 -0
  22. data/lib/google/cloud/retail/v2/product_service/rest/service_stub.rb +705 -0
  23. data/lib/google/cloud/retail/v2/product_service/rest.rb +54 -0
  24. data/lib/google/cloud/retail/v2/product_service.rb +6 -0
  25. data/lib/google/cloud/retail/v2/rest.rb +44 -0
  26. data/lib/google/cloud/retail/v2/search_service/rest/client.rb +598 -0
  27. data/lib/google/cloud/retail/v2/search_service/rest/service_stub.rb +116 -0
  28. data/lib/google/cloud/retail/v2/search_service/rest.rb +55 -0
  29. data/lib/google/cloud/retail/v2/search_service.rb +6 -0
  30. data/lib/google/cloud/retail/v2/serving_config_service/rest/client.rb +825 -0
  31. data/lib/google/cloud/retail/v2/serving_config_service/rest/service_stub.rb +465 -0
  32. data/lib/google/cloud/retail/v2/serving_config_service/rest.rb +52 -0
  33. data/lib/google/cloud/retail/v2/serving_config_service.rb +6 -0
  34. data/lib/google/cloud/retail/v2/user_event_service/rest/client.rb +755 -0
  35. data/lib/google/cloud/retail/v2/user_event_service/rest/operations.rb +828 -0
  36. data/lib/google/cloud/retail/v2/user_event_service/rest/service_stub.rb +347 -0
  37. data/lib/google/cloud/retail/v2/user_event_service/rest.rb +53 -0
  38. data/lib/google/cloud/retail/v2/user_event_service.rb +6 -0
  39. data/lib/google/cloud/retail/v2/version.rb +1 -1
  40. data/lib/google/cloud/retail/v2.rb +5 -0
  41. metadata +35 -5
@@ -0,0 +1,680 @@
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/control_service_pb"
21
+ require "google/cloud/retail/v2/control_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 ControlService
29
+ module Rest
30
+ ##
31
+ # REST client for the ControlService service.
32
+ #
33
+ # Service for modifying Control.
34
+ #
35
+ class Client
36
+ include Paths
37
+
38
+ # @private
39
+ attr_reader :control_service_stub
40
+
41
+ ##
42
+ # Configure the ControlService Client class.
43
+ #
44
+ # See {::Google::Cloud::Retail::V2::ControlService::Rest::Client::Configuration}
45
+ # for a description of the configuration fields.
46
+ #
47
+ # @example
48
+ #
49
+ # # Modify the configuration for all ControlService clients
50
+ # ::Google::Cloud::Retail::V2::ControlService::Rest::Client.configure do |config|
51
+ # config.timeout = 10.0
52
+ # end
53
+ #
54
+ # @yield [config] Configure the Client client.
55
+ # @yieldparam config [Client::Configuration]
56
+ #
57
+ # @return [Client::Configuration]
58
+ #
59
+ def self.configure
60
+ @configure ||= begin
61
+ namespace = ["Google", "Cloud", "Retail", "V2"]
62
+ parent_config = while namespace.any?
63
+ parent_name = namespace.join "::"
64
+ parent_const = const_get parent_name
65
+ break parent_const.configure if parent_const.respond_to? :configure
66
+ namespace.pop
67
+ end
68
+ default_config = Client::Configuration.new parent_config
69
+
70
+ default_config
71
+ end
72
+ yield @configure if block_given?
73
+ @configure
74
+ end
75
+
76
+ ##
77
+ # Configure the ControlService Client instance.
78
+ #
79
+ # The configuration is set to the derived mode, meaning that values can be changed,
80
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
81
+ # should be made on {Client.configure}.
82
+ #
83
+ # See {::Google::Cloud::Retail::V2::ControlService::Rest::Client::Configuration}
84
+ # for a description of the configuration fields.
85
+ #
86
+ # @yield [config] Configure the Client client.
87
+ # @yieldparam config [Client::Configuration]
88
+ #
89
+ # @return [Client::Configuration]
90
+ #
91
+ def configure
92
+ yield @config if block_given?
93
+ @config
94
+ end
95
+
96
+ ##
97
+ # Create a new ControlService REST client object.
98
+ #
99
+ # @example
100
+ #
101
+ # # Create a client using the default configuration
102
+ # client = ::Google::Cloud::Retail::V2::ControlService::Rest::Client.new
103
+ #
104
+ # # Create a client using a custom configuration
105
+ # client = ::Google::Cloud::Retail::V2::ControlService::Rest::Client.new do |config|
106
+ # config.timeout = 10.0
107
+ # end
108
+ #
109
+ # @yield [config] Configure the ControlService client.
110
+ # @yieldparam config [Client::Configuration]
111
+ #
112
+ def initialize
113
+ # Create the configuration object
114
+ @config = Configuration.new Client.configure
115
+
116
+ # Yield the configuration if needed
117
+ yield @config if block_given?
118
+
119
+ # Create credentials
120
+ credentials = @config.credentials
121
+ # Use self-signed JWT if the endpoint is unchanged from default,
122
+ # but only if the default endpoint does not have a region prefix.
123
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
124
+ !@config.endpoint.split(".").first.include?("-")
125
+ credentials ||= Credentials.default scope: @config.scope,
126
+ enable_self_signed_jwt: enable_self_signed_jwt
127
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
128
+ credentials = Credentials.new credentials, scope: @config.scope
129
+ end
130
+
131
+ @quota_project_id = @config.quota_project
132
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
133
+
134
+ @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
135
+ config.credentials = credentials
136
+ config.quota_project = @quota_project_id
137
+ config.endpoint = @config.endpoint
138
+ end
139
+
140
+ @control_service_stub = ::Google::Cloud::Retail::V2::ControlService::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
141
+ end
142
+
143
+ ##
144
+ # Get the associated client for mix-in of the Locations.
145
+ #
146
+ # @return [Google::Cloud::Location::Locations::Rest::Client]
147
+ #
148
+ attr_reader :location_client
149
+
150
+ # Service calls
151
+
152
+ ##
153
+ # Creates a Control.
154
+ #
155
+ # If the {::Google::Cloud::Retail::V2::Control Control} to create already exists,
156
+ # an ALREADY_EXISTS error is returned.
157
+ #
158
+ # @overload create_control(request, options = nil)
159
+ # Pass arguments to `create_control` via a request object, either of type
160
+ # {::Google::Cloud::Retail::V2::CreateControlRequest} or an equivalent Hash.
161
+ #
162
+ # @param request [::Google::Cloud::Retail::V2::CreateControlRequest, ::Hash]
163
+ # A request object representing the call parameters. Required. To specify no
164
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
165
+ # @param options [::Gapic::CallOptions, ::Hash]
166
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
167
+ #
168
+ # @overload create_control(parent: nil, control: nil, control_id: nil)
169
+ # Pass arguments to `create_control` via keyword arguments. Note that at
170
+ # least one keyword argument is required. To specify no parameters, or to keep all
171
+ # the default parameter values, pass an empty Hash as a request object (see above).
172
+ #
173
+ # @param parent [::String]
174
+ # Required. Full resource name of parent catalog. Format:
175
+ # `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}`
176
+ # @param control [::Google::Cloud::Retail::V2::Control, ::Hash]
177
+ # Required. The Control to create.
178
+ # @param control_id [::String]
179
+ # Required. The ID to use for the Control, which will become the final
180
+ # component of the Control's resource name.
181
+ #
182
+ # This value should be 4-63 characters, and valid characters
183
+ # are /[a-z][0-9]-_/.
184
+ # @yield [result, operation] Access the result along with the TransportOperation object
185
+ # @yieldparam result [::Google::Cloud::Retail::V2::Control]
186
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
187
+ #
188
+ # @return [::Google::Cloud::Retail::V2::Control]
189
+ #
190
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
191
+ def create_control request, options = nil
192
+ raise ::ArgumentError, "request must be provided" if request.nil?
193
+
194
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::CreateControlRequest
195
+
196
+ # Converts hash and nil to an options object
197
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
198
+
199
+ # Customize the options with defaults
200
+ call_metadata = @config.rpcs.create_control.metadata.to_h
201
+
202
+ # Set x-goog-api-client and x-goog-user-project headers
203
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
204
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
205
+ gapic_version: ::Google::Cloud::Retail::V2::VERSION,
206
+ transports_version_send: [:rest]
207
+
208
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
209
+
210
+ options.apply_defaults timeout: @config.rpcs.create_control.timeout,
211
+ metadata: call_metadata,
212
+ retry_policy: @config.rpcs.create_control.retry_policy
213
+
214
+ options.apply_defaults timeout: @config.timeout,
215
+ metadata: @config.metadata,
216
+ retry_policy: @config.retry_policy
217
+
218
+ @control_service_stub.create_control request, options do |result, operation|
219
+ yield result, operation if block_given?
220
+ return result
221
+ end
222
+ rescue ::Gapic::Rest::Error => e
223
+ raise ::Google::Cloud::Error.from_error(e)
224
+ end
225
+
226
+ ##
227
+ # Deletes a Control.
228
+ #
229
+ # If the {::Google::Cloud::Retail::V2::Control Control} to delete does not exist,
230
+ # a NOT_FOUND error is returned.
231
+ #
232
+ # @overload delete_control(request, options = nil)
233
+ # Pass arguments to `delete_control` via a request object, either of type
234
+ # {::Google::Cloud::Retail::V2::DeleteControlRequest} or an equivalent Hash.
235
+ #
236
+ # @param request [::Google::Cloud::Retail::V2::DeleteControlRequest, ::Hash]
237
+ # A request object representing the call parameters. Required. To specify no
238
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
239
+ # @param options [::Gapic::CallOptions, ::Hash]
240
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
241
+ #
242
+ # @overload delete_control(name: nil)
243
+ # Pass arguments to `delete_control` via keyword arguments. Note that at
244
+ # least one keyword argument is required. To specify no parameters, or to keep all
245
+ # the default parameter values, pass an empty Hash as a request object (see above).
246
+ #
247
+ # @param name [::String]
248
+ # Required. The resource name of the Control to delete. Format:
249
+ # `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}`
250
+ # @yield [result, operation] Access the result along with the TransportOperation object
251
+ # @yieldparam result [::Google::Protobuf::Empty]
252
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
253
+ #
254
+ # @return [::Google::Protobuf::Empty]
255
+ #
256
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
257
+ def delete_control request, options = nil
258
+ raise ::ArgumentError, "request must be provided" if request.nil?
259
+
260
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::DeleteControlRequest
261
+
262
+ # Converts hash and nil to an options object
263
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
264
+
265
+ # Customize the options with defaults
266
+ call_metadata = @config.rpcs.delete_control.metadata.to_h
267
+
268
+ # Set x-goog-api-client and x-goog-user-project headers
269
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
270
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
271
+ gapic_version: ::Google::Cloud::Retail::V2::VERSION,
272
+ transports_version_send: [:rest]
273
+
274
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
275
+
276
+ options.apply_defaults timeout: @config.rpcs.delete_control.timeout,
277
+ metadata: call_metadata,
278
+ retry_policy: @config.rpcs.delete_control.retry_policy
279
+
280
+ options.apply_defaults timeout: @config.timeout,
281
+ metadata: @config.metadata,
282
+ retry_policy: @config.retry_policy
283
+
284
+ @control_service_stub.delete_control request, options do |result, operation|
285
+ yield result, operation if block_given?
286
+ return result
287
+ end
288
+ rescue ::Gapic::Rest::Error => e
289
+ raise ::Google::Cloud::Error.from_error(e)
290
+ end
291
+
292
+ ##
293
+ # Updates a Control.
294
+ #
295
+ # {::Google::Cloud::Retail::V2::Control Control} cannot be set to a different
296
+ # oneof field, if so an INVALID_ARGUMENT is returned. If the
297
+ # {::Google::Cloud::Retail::V2::Control Control} to update does not exist, a
298
+ # NOT_FOUND error is returned.
299
+ #
300
+ # @overload update_control(request, options = nil)
301
+ # Pass arguments to `update_control` via a request object, either of type
302
+ # {::Google::Cloud::Retail::V2::UpdateControlRequest} or an equivalent Hash.
303
+ #
304
+ # @param request [::Google::Cloud::Retail::V2::UpdateControlRequest, ::Hash]
305
+ # A request object representing the call parameters. Required. To specify no
306
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
307
+ # @param options [::Gapic::CallOptions, ::Hash]
308
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
309
+ #
310
+ # @overload update_control(control: nil, update_mask: nil)
311
+ # Pass arguments to `update_control` via keyword arguments. Note that at
312
+ # least one keyword argument is required. To specify no parameters, or to keep all
313
+ # the default parameter values, pass an empty Hash as a request object (see above).
314
+ #
315
+ # @param control [::Google::Cloud::Retail::V2::Control, ::Hash]
316
+ # Required. The Control to update.
317
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
318
+ # Indicates which fields in the provided
319
+ # {::Google::Cloud::Retail::V2::Control Control} to update. The following are NOT
320
+ # supported:
321
+ #
322
+ # * {::Google::Cloud::Retail::V2::Control#name Control.name}
323
+ #
324
+ # If not set or empty, all supported fields are updated.
325
+ # @yield [result, operation] Access the result along with the TransportOperation object
326
+ # @yieldparam result [::Google::Cloud::Retail::V2::Control]
327
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
328
+ #
329
+ # @return [::Google::Cloud::Retail::V2::Control]
330
+ #
331
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
332
+ def update_control request, options = nil
333
+ raise ::ArgumentError, "request must be provided" if request.nil?
334
+
335
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::UpdateControlRequest
336
+
337
+ # Converts hash and nil to an options object
338
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
339
+
340
+ # Customize the options with defaults
341
+ call_metadata = @config.rpcs.update_control.metadata.to_h
342
+
343
+ # Set x-goog-api-client and x-goog-user-project headers
344
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
345
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
346
+ gapic_version: ::Google::Cloud::Retail::V2::VERSION,
347
+ transports_version_send: [:rest]
348
+
349
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
350
+
351
+ options.apply_defaults timeout: @config.rpcs.update_control.timeout,
352
+ metadata: call_metadata,
353
+ retry_policy: @config.rpcs.update_control.retry_policy
354
+
355
+ options.apply_defaults timeout: @config.timeout,
356
+ metadata: @config.metadata,
357
+ retry_policy: @config.retry_policy
358
+
359
+ @control_service_stub.update_control request, options do |result, operation|
360
+ yield result, operation if block_given?
361
+ return result
362
+ end
363
+ rescue ::Gapic::Rest::Error => e
364
+ raise ::Google::Cloud::Error.from_error(e)
365
+ end
366
+
367
+ ##
368
+ # Gets a Control.
369
+ #
370
+ # @overload get_control(request, options = nil)
371
+ # Pass arguments to `get_control` via a request object, either of type
372
+ # {::Google::Cloud::Retail::V2::GetControlRequest} or an equivalent Hash.
373
+ #
374
+ # @param request [::Google::Cloud::Retail::V2::GetControlRequest, ::Hash]
375
+ # A request object representing the call parameters. Required. To specify no
376
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
377
+ # @param options [::Gapic::CallOptions, ::Hash]
378
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
379
+ #
380
+ # @overload get_control(name: nil)
381
+ # Pass arguments to `get_control` via keyword arguments. Note that at
382
+ # least one keyword argument is required. To specify no parameters, or to keep all
383
+ # the default parameter values, pass an empty Hash as a request object (see above).
384
+ #
385
+ # @param name [::String]
386
+ # Required. The resource name of the Control to get. Format:
387
+ # `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}`
388
+ # @yield [result, operation] Access the result along with the TransportOperation object
389
+ # @yieldparam result [::Google::Cloud::Retail::V2::Control]
390
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
391
+ #
392
+ # @return [::Google::Cloud::Retail::V2::Control]
393
+ #
394
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
395
+ def get_control request, options = nil
396
+ raise ::ArgumentError, "request must be provided" if request.nil?
397
+
398
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::GetControlRequest
399
+
400
+ # Converts hash and nil to an options object
401
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
402
+
403
+ # Customize the options with defaults
404
+ call_metadata = @config.rpcs.get_control.metadata.to_h
405
+
406
+ # Set x-goog-api-client and x-goog-user-project headers
407
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
408
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
409
+ gapic_version: ::Google::Cloud::Retail::V2::VERSION,
410
+ transports_version_send: [:rest]
411
+
412
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
413
+
414
+ options.apply_defaults timeout: @config.rpcs.get_control.timeout,
415
+ metadata: call_metadata,
416
+ retry_policy: @config.rpcs.get_control.retry_policy
417
+
418
+ options.apply_defaults timeout: @config.timeout,
419
+ metadata: @config.metadata,
420
+ retry_policy: @config.retry_policy
421
+
422
+ @control_service_stub.get_control request, options do |result, operation|
423
+ yield result, operation if block_given?
424
+ return result
425
+ end
426
+ rescue ::Gapic::Rest::Error => e
427
+ raise ::Google::Cloud::Error.from_error(e)
428
+ end
429
+
430
+ ##
431
+ # Lists all Controls by their parent
432
+ # {::Google::Cloud::Retail::V2::Catalog Catalog}.
433
+ #
434
+ # @overload list_controls(request, options = nil)
435
+ # Pass arguments to `list_controls` via a request object, either of type
436
+ # {::Google::Cloud::Retail::V2::ListControlsRequest} or an equivalent Hash.
437
+ #
438
+ # @param request [::Google::Cloud::Retail::V2::ListControlsRequest, ::Hash]
439
+ # A request object representing the call parameters. Required. To specify no
440
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
441
+ # @param options [::Gapic::CallOptions, ::Hash]
442
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
443
+ #
444
+ # @overload list_controls(parent: nil, page_size: nil, page_token: nil, filter: nil)
445
+ # Pass arguments to `list_controls` via keyword arguments. Note that at
446
+ # least one keyword argument is required. To specify no parameters, or to keep all
447
+ # the default parameter values, pass an empty Hash as a request object (see above).
448
+ #
449
+ # @param parent [::String]
450
+ # Required. The catalog resource name. Format:
451
+ # `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}`
452
+ # @param page_size [::Integer]
453
+ # Optional. Maximum number of results to return. If unspecified, defaults
454
+ # to 50. Max allowed value is 1000.
455
+ # @param page_token [::String]
456
+ # Optional. A page token, received from a previous `ListControls` call.
457
+ # Provide this to retrieve the subsequent page.
458
+ # @param filter [::String]
459
+ # Optional. A filter to apply on the list results. Supported features:
460
+ #
461
+ # * List all the products under the parent branch if
462
+ # {::Google::Cloud::Retail::V2::ListControlsRequest#filter filter} is unset.
463
+ # * List controls that are used in a single ServingConfig:
464
+ # 'serving_config = "boosted_home_page_cvr"'
465
+ # @yield [result, operation] Access the result along with the TransportOperation object
466
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Retail::V2::Control>]
467
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
468
+ #
469
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Retail::V2::Control>]
470
+ #
471
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
472
+ def list_controls 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::ListControlsRequest
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.list_controls.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.list_controls.timeout,
492
+ metadata: call_metadata,
493
+ retry_policy: @config.rpcs.list_controls.retry_policy
494
+
495
+ options.apply_defaults timeout: @config.timeout,
496
+ metadata: @config.metadata,
497
+ retry_policy: @config.retry_policy
498
+
499
+ @control_service_stub.list_controls request, options do |result, operation|
500
+ result = ::Gapic::Rest::PagedEnumerable.new @control_service_stub, :list_controls, "controls", request, result, options
501
+ yield result, operation if block_given?
502
+ return result
503
+ end
504
+ rescue ::Gapic::Rest::Error => e
505
+ raise ::Google::Cloud::Error.from_error(e)
506
+ end
507
+
508
+ ##
509
+ # Configuration class for the ControlService REST API.
510
+ #
511
+ # This class represents the configuration for ControlService REST,
512
+ # providing control over timeouts, retry behavior, logging, transport
513
+ # parameters, and other low-level controls. Certain parameters can also be
514
+ # applied individually to specific RPCs. See
515
+ # {::Google::Cloud::Retail::V2::ControlService::Rest::Client::Configuration::Rpcs}
516
+ # for a list of RPCs that can be configured independently.
517
+ #
518
+ # Configuration can be applied globally to all clients, or to a single client
519
+ # on construction.
520
+ #
521
+ # @example
522
+ #
523
+ # # Modify the global config, setting the timeout for
524
+ # # create_control to 20 seconds,
525
+ # # and all remaining timeouts to 10 seconds.
526
+ # ::Google::Cloud::Retail::V2::ControlService::Rest::Client.configure do |config|
527
+ # config.timeout = 10.0
528
+ # config.rpcs.create_control.timeout = 20.0
529
+ # end
530
+ #
531
+ # # Apply the above configuration only to a new client.
532
+ # client = ::Google::Cloud::Retail::V2::ControlService::Rest::Client.new do |config|
533
+ # config.timeout = 10.0
534
+ # config.rpcs.create_control.timeout = 20.0
535
+ # end
536
+ #
537
+ # @!attribute [rw] endpoint
538
+ # The hostname or hostname:port of the service endpoint.
539
+ # Defaults to `"retail.googleapis.com"`.
540
+ # @return [::String]
541
+ # @!attribute [rw] credentials
542
+ # Credentials to send with calls. You may provide any of the following types:
543
+ # * (`String`) The path to a service account key file in JSON format
544
+ # * (`Hash`) A service account key as a Hash
545
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
546
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
547
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
548
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
549
+ # * (`nil`) indicating no credentials
550
+ # @return [::Object]
551
+ # @!attribute [rw] scope
552
+ # The OAuth scopes
553
+ # @return [::Array<::String>]
554
+ # @!attribute [rw] lib_name
555
+ # The library name as recorded in instrumentation and logging
556
+ # @return [::String]
557
+ # @!attribute [rw] lib_version
558
+ # The library version as recorded in instrumentation and logging
559
+ # @return [::String]
560
+ # @!attribute [rw] timeout
561
+ # The call timeout in seconds.
562
+ # @return [::Numeric]
563
+ # @!attribute [rw] metadata
564
+ # Additional headers to be sent with the call.
565
+ # @return [::Hash{::Symbol=>::String}]
566
+ # @!attribute [rw] retry_policy
567
+ # The retry policy. The value is a hash with the following keys:
568
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
569
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
570
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
571
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
572
+ # trigger a retry.
573
+ # @return [::Hash]
574
+ # @!attribute [rw] quota_project
575
+ # A separate project against which to charge quota.
576
+ # @return [::String]
577
+ #
578
+ class Configuration
579
+ extend ::Gapic::Config
580
+
581
+ config_attr :endpoint, "retail.googleapis.com", ::String
582
+ config_attr :credentials, nil do |value|
583
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
584
+ allowed.any? { |klass| klass === value }
585
+ end
586
+ config_attr :scope, nil, ::String, ::Array, nil
587
+ config_attr :lib_name, nil, ::String, nil
588
+ config_attr :lib_version, nil, ::String, nil
589
+ config_attr :timeout, nil, ::Numeric, nil
590
+ config_attr :metadata, nil, ::Hash, nil
591
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
592
+ config_attr :quota_project, nil, ::String, nil
593
+
594
+ # @private
595
+ def initialize parent_config = nil
596
+ @parent_config = parent_config unless parent_config.nil?
597
+
598
+ yield self if block_given?
599
+ end
600
+
601
+ ##
602
+ # Configurations for individual RPCs
603
+ # @return [Rpcs]
604
+ #
605
+ def rpcs
606
+ @rpcs ||= begin
607
+ parent_rpcs = nil
608
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
609
+ Rpcs.new parent_rpcs
610
+ end
611
+ end
612
+
613
+ ##
614
+ # Configuration RPC class for the ControlService API.
615
+ #
616
+ # Includes fields providing the configuration for each RPC in this service.
617
+ # Each configuration object is of type `Gapic::Config::Method` and includes
618
+ # the following configuration fields:
619
+ #
620
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
621
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
622
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
623
+ # include the following keys:
624
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
625
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
626
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
627
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
628
+ # trigger a retry.
629
+ #
630
+ class Rpcs
631
+ ##
632
+ # RPC-specific configuration for `create_control`
633
+ # @return [::Gapic::Config::Method]
634
+ #
635
+ attr_reader :create_control
636
+ ##
637
+ # RPC-specific configuration for `delete_control`
638
+ # @return [::Gapic::Config::Method]
639
+ #
640
+ attr_reader :delete_control
641
+ ##
642
+ # RPC-specific configuration for `update_control`
643
+ # @return [::Gapic::Config::Method]
644
+ #
645
+ attr_reader :update_control
646
+ ##
647
+ # RPC-specific configuration for `get_control`
648
+ # @return [::Gapic::Config::Method]
649
+ #
650
+ attr_reader :get_control
651
+ ##
652
+ # RPC-specific configuration for `list_controls`
653
+ # @return [::Gapic::Config::Method]
654
+ #
655
+ attr_reader :list_controls
656
+
657
+ # @private
658
+ def initialize parent_rpcs = nil
659
+ create_control_config = parent_rpcs.create_control if parent_rpcs.respond_to? :create_control
660
+ @create_control = ::Gapic::Config::Method.new create_control_config
661
+ delete_control_config = parent_rpcs.delete_control if parent_rpcs.respond_to? :delete_control
662
+ @delete_control = ::Gapic::Config::Method.new delete_control_config
663
+ update_control_config = parent_rpcs.update_control if parent_rpcs.respond_to? :update_control
664
+ @update_control = ::Gapic::Config::Method.new update_control_config
665
+ get_control_config = parent_rpcs.get_control if parent_rpcs.respond_to? :get_control
666
+ @get_control = ::Gapic::Config::Method.new get_control_config
667
+ list_controls_config = parent_rpcs.list_controls if parent_rpcs.respond_to? :list_controls
668
+ @list_controls = ::Gapic::Config::Method.new list_controls_config
669
+
670
+ yield self if block_given?
671
+ end
672
+ end
673
+ end
674
+ end
675
+ end
676
+ end
677
+ end
678
+ end
679
+ end
680
+ end