google-cloud-retail-v2 0.8.0 → 0.11.0

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