google-cloud-retail-v2 1.0.1 → 1.2.0

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