google-cloud-discovery_engine-v1beta 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/lib/google/cloud/discovery_engine/v1beta/conversational_search_service/client.rb +742 -0
  3. data/lib/google/cloud/discovery_engine/v1beta/conversational_search_service/paths.rb +199 -0
  4. data/lib/google/cloud/discovery_engine/v1beta/conversational_search_service/rest/client.rb +693 -0
  5. data/lib/google/cloud/discovery_engine/v1beta/conversational_search_service/rest/service_stub.rb +520 -0
  6. data/lib/google/cloud/discovery_engine/v1beta/document_service/client.rb +48 -23
  7. data/lib/google/cloud/discovery_engine/v1beta/document_service/paths.rb +21 -0
  8. data/lib/google/cloud/discovery_engine/v1beta/document_service/rest/client.rb +48 -23
  9. data/lib/google/cloud/discovery_engine/v1beta/engine_service/client.rb +296 -0
  10. data/lib/google/cloud/discovery_engine/v1beta/engine_service/rest/client.rb +275 -0
  11. data/lib/google/cloud/discovery_engine/v1beta/engine_service/rest/service_stub.rb +180 -0
  12. data/lib/google/cloud/discovery_engine/v1beta/grounded_generation_service/client.rb +449 -0
  13. data/lib/google/cloud/discovery_engine/v1beta/grounded_generation_service/credentials.rb +47 -0
  14. data/lib/google/cloud/discovery_engine/v1beta/grounded_generation_service/paths.rb +52 -0
  15. data/lib/google/cloud/discovery_engine/v1beta/grounded_generation_service/rest/client.rb +416 -0
  16. data/lib/google/cloud/discovery_engine/v1beta/grounded_generation_service/rest/service_stub.rb +129 -0
  17. data/lib/google/cloud/discovery_engine/v1beta/grounded_generation_service/rest.rb +52 -0
  18. data/lib/google/cloud/discovery_engine/v1beta/grounded_generation_service.rb +55 -0
  19. data/lib/google/cloud/discovery_engine/v1beta/rank_service/client.rb +459 -0
  20. data/lib/google/cloud/discovery_engine/v1beta/rank_service/credentials.rb +47 -0
  21. data/lib/google/cloud/discovery_engine/v1beta/rank_service/paths.rb +52 -0
  22. data/lib/google/cloud/discovery_engine/v1beta/rank_service/rest/client.rb +426 -0
  23. data/lib/google/cloud/discovery_engine/v1beta/rank_service/rest/service_stub.rb +129 -0
  24. data/lib/google/cloud/discovery_engine/v1beta/rank_service/rest.rb +52 -0
  25. data/lib/google/cloud/discovery_engine/v1beta/rank_service.rb +55 -0
  26. data/lib/google/cloud/discovery_engine/v1beta/rest.rb +2 -0
  27. data/lib/google/cloud/discovery_engine/v1beta/search_service/client.rb +11 -6
  28. data/lib/google/cloud/discovery_engine/v1beta/search_service/rest/client.rb +11 -6
  29. data/lib/google/cloud/discovery_engine/v1beta/version.rb +1 -1
  30. data/lib/google/cloud/discovery_engine/v1beta.rb +2 -0
  31. data/lib/google/cloud/discoveryengine/v1beta/answer_pb.rb +67 -0
  32. data/lib/google/cloud/discoveryengine/v1beta/common_pb.rb +1 -1
  33. data/lib/google/cloud/discoveryengine/v1beta/conversational_search_service_pb.rb +32 -1
  34. data/lib/google/cloud/discoveryengine/v1beta/conversational_search_service_services_pb.rb +25 -0
  35. data/lib/google/cloud/discoveryengine/v1beta/document_processing_config_pb.rb +1 -1
  36. data/lib/google/cloud/discoveryengine/v1beta/document_service_pb.rb +3 -1
  37. data/lib/google/cloud/discoveryengine/v1beta/engine_service_pb.rb +6 -1
  38. data/lib/google/cloud/discoveryengine/v1beta/engine_service_services_pb.rb +12 -0
  39. data/lib/google/cloud/discoveryengine/v1beta/grounded_generation_service_pb.rb +52 -0
  40. data/lib/google/cloud/discoveryengine/v1beta/grounded_generation_service_services_pb.rb +45 -0
  41. data/lib/google/cloud/discoveryengine/v1beta/grounding_pb.rb +46 -0
  42. data/lib/google/cloud/discoveryengine/v1beta/import_config_pb.rb +13 -1
  43. data/lib/google/cloud/discoveryengine/v1beta/rank_service_pb.rb +49 -0
  44. data/lib/google/cloud/discoveryengine/v1beta/rank_service_services_pb.rb +45 -0
  45. data/lib/google/cloud/discoveryengine/v1beta/search_service_pb.rb +7 -1
  46. data/lib/google/cloud/discoveryengine/v1beta/search_tuning_service_pb.rb +1 -1
  47. data/lib/google/cloud/discoveryengine/v1beta/session_pb.rb +50 -0
  48. data/proto_docs/google/cloud/discoveryengine/v1beta/answer.rb +354 -0
  49. data/proto_docs/google/cloud/discoveryengine/v1beta/common.rb +9 -1
  50. data/proto_docs/google/cloud/discoveryengine/v1beta/conversational_search_service.rb +475 -0
  51. data/proto_docs/google/cloud/discoveryengine/v1beta/document_processing_config.rb +3 -5
  52. data/proto_docs/google/cloud/discoveryengine/v1beta/document_service.rb +4 -0
  53. data/proto_docs/google/cloud/discoveryengine/v1beta/engine.rb +2 -2
  54. data/proto_docs/google/cloud/discoveryengine/v1beta/engine_service.rb +51 -0
  55. data/proto_docs/google/cloud/discoveryengine/v1beta/grounded_generation_service.rb +106 -0
  56. data/proto_docs/google/cloud/discoveryengine/v1beta/grounding.rb +76 -0
  57. data/proto_docs/google/cloud/discoveryengine/v1beta/import_config.rb +310 -24
  58. data/proto_docs/google/cloud/discoveryengine/v1beta/rank_service.rb +99 -0
  59. data/proto_docs/google/cloud/discoveryengine/v1beta/search_service.rb +154 -22
  60. data/proto_docs/google/cloud/discoveryengine/v1beta/search_tuning_service.rb +16 -1
  61. data/proto_docs/google/cloud/discoveryengine/v1beta/session.rb +85 -0
  62. data/proto_docs/google/cloud/discoveryengine/v1beta/user_event.rb +1 -1
  63. metadata +28 -2
@@ -0,0 +1,426 @@
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/discoveryengine/v1beta/rank_service_pb"
21
+ require "google/cloud/discovery_engine/v1beta/rank_service/rest/service_stub"
22
+ require "google/cloud/location/rest"
23
+
24
+ module Google
25
+ module Cloud
26
+ module DiscoveryEngine
27
+ module V1beta
28
+ module RankService
29
+ module Rest
30
+ ##
31
+ # REST client for the RankService service.
32
+ #
33
+ # Service for ranking text records.
34
+ #
35
+ class Client
36
+ # @private
37
+ DEFAULT_ENDPOINT_TEMPLATE = "discoveryengine.$UNIVERSE_DOMAIN$"
38
+
39
+ include Paths
40
+
41
+ # @private
42
+ attr_reader :rank_service_stub
43
+
44
+ ##
45
+ # Configure the RankService Client class.
46
+ #
47
+ # See {::Google::Cloud::DiscoveryEngine::V1beta::RankService::Rest::Client::Configuration}
48
+ # for a description of the configuration fields.
49
+ #
50
+ # @example
51
+ #
52
+ # # Modify the configuration for all RankService clients
53
+ # ::Google::Cloud::DiscoveryEngine::V1beta::RankService::Rest::Client.configure do |config|
54
+ # config.timeout = 10.0
55
+ # end
56
+ #
57
+ # @yield [config] Configure the Client client.
58
+ # @yieldparam config [Client::Configuration]
59
+ #
60
+ # @return [Client::Configuration]
61
+ #
62
+ def self.configure
63
+ @configure ||= begin
64
+ namespace = ["Google", "Cloud", "DiscoveryEngine", "V1beta"]
65
+ parent_config = while namespace.any?
66
+ parent_name = namespace.join "::"
67
+ parent_const = const_get parent_name
68
+ break parent_const.configure if parent_const.respond_to? :configure
69
+ namespace.pop
70
+ end
71
+ default_config = Client::Configuration.new parent_config
72
+
73
+ default_config.timeout = 30.0
74
+ default_config.retry_policy = {
75
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
76
+ }
77
+
78
+ default_config
79
+ end
80
+ yield @configure if block_given?
81
+ @configure
82
+ end
83
+
84
+ ##
85
+ # Configure the RankService Client instance.
86
+ #
87
+ # The configuration is set to the derived mode, meaning that values can be changed,
88
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
89
+ # should be made on {Client.configure}.
90
+ #
91
+ # See {::Google::Cloud::DiscoveryEngine::V1beta::RankService::Rest::Client::Configuration}
92
+ # for a description of the configuration fields.
93
+ #
94
+ # @yield [config] Configure the Client client.
95
+ # @yieldparam config [Client::Configuration]
96
+ #
97
+ # @return [Client::Configuration]
98
+ #
99
+ def configure
100
+ yield @config if block_given?
101
+ @config
102
+ end
103
+
104
+ ##
105
+ # The effective universe domain
106
+ #
107
+ # @return [String]
108
+ #
109
+ def universe_domain
110
+ @rank_service_stub.universe_domain
111
+ end
112
+
113
+ ##
114
+ # Create a new RankService REST client object.
115
+ #
116
+ # @example
117
+ #
118
+ # # Create a client using the default configuration
119
+ # client = ::Google::Cloud::DiscoveryEngine::V1beta::RankService::Rest::Client.new
120
+ #
121
+ # # Create a client using a custom configuration
122
+ # client = ::Google::Cloud::DiscoveryEngine::V1beta::RankService::Rest::Client.new do |config|
123
+ # config.timeout = 10.0
124
+ # end
125
+ #
126
+ # @yield [config] Configure the RankService client.
127
+ # @yieldparam config [Client::Configuration]
128
+ #
129
+ def initialize
130
+ # Create the configuration object
131
+ @config = Configuration.new Client.configure
132
+
133
+ # Yield the configuration if needed
134
+ yield @config if block_given?
135
+
136
+ # Create credentials
137
+ credentials = @config.credentials
138
+ # Use self-signed JWT if the endpoint is unchanged from default,
139
+ # but only if the default endpoint does not have a region prefix.
140
+ enable_self_signed_jwt = @config.endpoint.nil? ||
141
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
142
+ !@config.endpoint.split(".").first.include?("-"))
143
+ credentials ||= Credentials.default scope: @config.scope,
144
+ enable_self_signed_jwt: enable_self_signed_jwt
145
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
146
+ credentials = Credentials.new credentials, scope: @config.scope
147
+ end
148
+
149
+ @quota_project_id = @config.quota_project
150
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
151
+
152
+ @rank_service_stub = ::Google::Cloud::DiscoveryEngine::V1beta::RankService::Rest::ServiceStub.new(
153
+ endpoint: @config.endpoint,
154
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
155
+ universe_domain: @config.universe_domain,
156
+ credentials: credentials
157
+ )
158
+
159
+ @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
160
+ config.credentials = credentials
161
+ config.quota_project = @quota_project_id
162
+ config.endpoint = @rank_service_stub.endpoint
163
+ config.universe_domain = @rank_service_stub.universe_domain
164
+ end
165
+ end
166
+
167
+ ##
168
+ # Get the associated client for mix-in of the Locations.
169
+ #
170
+ # @return [Google::Cloud::Location::Locations::Rest::Client]
171
+ #
172
+ attr_reader :location_client
173
+
174
+ # Service calls
175
+
176
+ ##
177
+ # Ranks a list of text records based on the given input query.
178
+ #
179
+ # @overload rank(request, options = nil)
180
+ # Pass arguments to `rank` via a request object, either of type
181
+ # {::Google::Cloud::DiscoveryEngine::V1beta::RankRequest} or an equivalent Hash.
182
+ #
183
+ # @param request [::Google::Cloud::DiscoveryEngine::V1beta::RankRequest, ::Hash]
184
+ # A request object representing the call parameters. Required. To specify no
185
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
186
+ # @param options [::Gapic::CallOptions, ::Hash]
187
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
188
+ #
189
+ # @overload rank(ranking_config: nil, model: nil, top_n: nil, query: nil, records: nil, ignore_record_details_in_response: nil)
190
+ # Pass arguments to `rank` via keyword arguments. Note that at
191
+ # least one keyword argument is required. To specify no parameters, or to keep all
192
+ # the default parameter values, pass an empty Hash as a request object (see above).
193
+ #
194
+ # @param ranking_config [::String]
195
+ # Required. The resource name of the rank service config, such as
196
+ # `projects/{project_num}/locations/{location_id}/rankingConfigs/default_ranking_config`.
197
+ # @param model [::String]
198
+ # The identifier of the model to use. It is one of:
199
+ #
200
+ # * `semantic-ranker-512@latest`: Semantic ranking model with maxiumn input
201
+ # token size 512.
202
+ #
203
+ # It is set to `semantic-ranker-512@latest` by default if unspecified.
204
+ # @param top_n [::Integer]
205
+ # The number of results to return. If this is unset or no bigger than zero,
206
+ # returns all results.
207
+ # @param query [::String]
208
+ # The query to use.
209
+ # @param records [::Array<::Google::Cloud::DiscoveryEngine::V1beta::RankingRecord, ::Hash>]
210
+ # Required. A list of records to rank. At most 200 records to rank.
211
+ # @param ignore_record_details_in_response [::Boolean]
212
+ # If true, the response will contain only record ID and score. By default, it
213
+ # is false, the response will contain record details.
214
+ # @yield [result, operation] Access the result along with the TransportOperation object
215
+ # @yieldparam result [::Google::Cloud::DiscoveryEngine::V1beta::RankResponse]
216
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
217
+ #
218
+ # @return [::Google::Cloud::DiscoveryEngine::V1beta::RankResponse]
219
+ #
220
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
221
+ #
222
+ # @example Basic example
223
+ # require "google/cloud/discovery_engine/v1beta"
224
+ #
225
+ # # Create a client object. The client can be reused for multiple calls.
226
+ # client = Google::Cloud::DiscoveryEngine::V1beta::RankService::Rest::Client.new
227
+ #
228
+ # # Create a request. To set request fields, pass in keyword arguments.
229
+ # request = Google::Cloud::DiscoveryEngine::V1beta::RankRequest.new
230
+ #
231
+ # # Call the rank method.
232
+ # result = client.rank request
233
+ #
234
+ # # The returned object is of type Google::Cloud::DiscoveryEngine::V1beta::RankResponse.
235
+ # p result
236
+ #
237
+ def rank request, options = nil
238
+ raise ::ArgumentError, "request must be provided" if request.nil?
239
+
240
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1beta::RankRequest
241
+
242
+ # Converts hash and nil to an options object
243
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
244
+
245
+ # Customize the options with defaults
246
+ call_metadata = @config.rpcs.rank.metadata.to_h
247
+
248
+ # Set x-goog-api-client and x-goog-user-project headers
249
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
250
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
251
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1beta::VERSION,
252
+ transports_version_send: [:rest]
253
+
254
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
255
+
256
+ options.apply_defaults timeout: @config.rpcs.rank.timeout,
257
+ metadata: call_metadata,
258
+ retry_policy: @config.rpcs.rank.retry_policy
259
+
260
+ options.apply_defaults timeout: @config.timeout,
261
+ metadata: @config.metadata,
262
+ retry_policy: @config.retry_policy
263
+
264
+ @rank_service_stub.rank request, options do |result, operation|
265
+ yield result, operation if block_given?
266
+ return result
267
+ end
268
+ rescue ::Gapic::Rest::Error => e
269
+ raise ::Google::Cloud::Error.from_error(e)
270
+ end
271
+
272
+ ##
273
+ # Configuration class for the RankService REST API.
274
+ #
275
+ # This class represents the configuration for RankService REST,
276
+ # providing control over timeouts, retry behavior, logging, transport
277
+ # parameters, and other low-level controls. Certain parameters can also be
278
+ # applied individually to specific RPCs. See
279
+ # {::Google::Cloud::DiscoveryEngine::V1beta::RankService::Rest::Client::Configuration::Rpcs}
280
+ # for a list of RPCs that can be configured independently.
281
+ #
282
+ # Configuration can be applied globally to all clients, or to a single client
283
+ # on construction.
284
+ #
285
+ # @example
286
+ #
287
+ # # Modify the global config, setting the timeout for
288
+ # # rank to 20 seconds,
289
+ # # and all remaining timeouts to 10 seconds.
290
+ # ::Google::Cloud::DiscoveryEngine::V1beta::RankService::Rest::Client.configure do |config|
291
+ # config.timeout = 10.0
292
+ # config.rpcs.rank.timeout = 20.0
293
+ # end
294
+ #
295
+ # # Apply the above configuration only to a new client.
296
+ # client = ::Google::Cloud::DiscoveryEngine::V1beta::RankService::Rest::Client.new do |config|
297
+ # config.timeout = 10.0
298
+ # config.rpcs.rank.timeout = 20.0
299
+ # end
300
+ #
301
+ # @!attribute [rw] endpoint
302
+ # A custom service endpoint, as a hostname or hostname:port. The default is
303
+ # nil, indicating to use the default endpoint in the current universe domain.
304
+ # @return [::String,nil]
305
+ # @!attribute [rw] credentials
306
+ # Credentials to send with calls. You may provide any of the following types:
307
+ # * (`String`) The path to a service account key file in JSON format
308
+ # * (`Hash`) A service account key as a Hash
309
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
310
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
311
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
312
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
313
+ # * (`nil`) indicating no credentials
314
+ # @return [::Object]
315
+ # @!attribute [rw] scope
316
+ # The OAuth scopes
317
+ # @return [::Array<::String>]
318
+ # @!attribute [rw] lib_name
319
+ # The library name as recorded in instrumentation and logging
320
+ # @return [::String]
321
+ # @!attribute [rw] lib_version
322
+ # The library version as recorded in instrumentation and logging
323
+ # @return [::String]
324
+ # @!attribute [rw] timeout
325
+ # The call timeout in seconds.
326
+ # @return [::Numeric]
327
+ # @!attribute [rw] metadata
328
+ # Additional headers to be sent with the call.
329
+ # @return [::Hash{::Symbol=>::String}]
330
+ # @!attribute [rw] retry_policy
331
+ # The retry policy. The value is a hash with the following keys:
332
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
333
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
334
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
335
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
336
+ # trigger a retry.
337
+ # @return [::Hash]
338
+ # @!attribute [rw] quota_project
339
+ # A separate project against which to charge quota.
340
+ # @return [::String]
341
+ # @!attribute [rw] universe_domain
342
+ # The universe domain within which to make requests. This determines the
343
+ # default endpoint URL. The default value of nil uses the environment
344
+ # universe (usually the default "googleapis.com" universe).
345
+ # @return [::String,nil]
346
+ #
347
+ class Configuration
348
+ extend ::Gapic::Config
349
+
350
+ # @private
351
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
352
+ DEFAULT_ENDPOINT = "discoveryengine.googleapis.com"
353
+
354
+ config_attr :endpoint, nil, ::String, nil
355
+ config_attr :credentials, nil do |value|
356
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
357
+ allowed.any? { |klass| klass === value }
358
+ end
359
+ config_attr :scope, nil, ::String, ::Array, nil
360
+ config_attr :lib_name, nil, ::String, nil
361
+ config_attr :lib_version, nil, ::String, nil
362
+ config_attr :timeout, nil, ::Numeric, nil
363
+ config_attr :metadata, nil, ::Hash, nil
364
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
365
+ config_attr :quota_project, nil, ::String, nil
366
+ config_attr :universe_domain, nil, ::String, nil
367
+
368
+ # @private
369
+ def initialize parent_config = nil
370
+ @parent_config = parent_config unless parent_config.nil?
371
+
372
+ yield self if block_given?
373
+ end
374
+
375
+ ##
376
+ # Configurations for individual RPCs
377
+ # @return [Rpcs]
378
+ #
379
+ def rpcs
380
+ @rpcs ||= begin
381
+ parent_rpcs = nil
382
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
383
+ Rpcs.new parent_rpcs
384
+ end
385
+ end
386
+
387
+ ##
388
+ # Configuration RPC class for the RankService API.
389
+ #
390
+ # Includes fields providing the configuration for each RPC in this service.
391
+ # Each configuration object is of type `Gapic::Config::Method` and includes
392
+ # the following configuration fields:
393
+ #
394
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
395
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
396
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
397
+ # include the following keys:
398
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
399
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
400
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
401
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
402
+ # trigger a retry.
403
+ #
404
+ class Rpcs
405
+ ##
406
+ # RPC-specific configuration for `rank`
407
+ # @return [::Gapic::Config::Method]
408
+ #
409
+ attr_reader :rank
410
+
411
+ # @private
412
+ def initialize parent_rpcs = nil
413
+ rank_config = parent_rpcs.rank if parent_rpcs.respond_to? :rank
414
+ @rank = ::Gapic::Config::Method.new rank_config
415
+
416
+ yield self if block_given?
417
+ end
418
+ end
419
+ end
420
+ end
421
+ end
422
+ end
423
+ end
424
+ end
425
+ end
426
+ end
@@ -0,0 +1,129 @@
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/discoveryengine/v1beta/rank_service_pb"
20
+
21
+ module Google
22
+ module Cloud
23
+ module DiscoveryEngine
24
+ module V1beta
25
+ module RankService
26
+ module Rest
27
+ ##
28
+ # REST service stub for the RankService service.
29
+ # Service stub contains baseline method implementations
30
+ # including transcoding, making the REST call, and deserialing the response.
31
+ #
32
+ class ServiceStub
33
+ def initialize endpoint:, endpoint_template:, universe_domain:, credentials:
34
+ # These require statements are intentionally placed here to initialize
35
+ # the REST modules only when it's required.
36
+ require "gapic/rest"
37
+
38
+ @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint,
39
+ endpoint_template: endpoint_template,
40
+ universe_domain: universe_domain,
41
+ credentials: credentials,
42
+ numeric_enums: true,
43
+ raise_faraday_errors: false
44
+ end
45
+
46
+ ##
47
+ # The effective universe domain
48
+ #
49
+ # @return [String]
50
+ #
51
+ def universe_domain
52
+ @client_stub.universe_domain
53
+ end
54
+
55
+ ##
56
+ # The effective endpoint
57
+ #
58
+ # @return [String]
59
+ #
60
+ def endpoint
61
+ @client_stub.endpoint
62
+ end
63
+
64
+ ##
65
+ # Baseline implementation for the rank REST call
66
+ #
67
+ # @param request_pb [::Google::Cloud::DiscoveryEngine::V1beta::RankRequest]
68
+ # A request object representing the call parameters. Required.
69
+ # @param options [::Gapic::CallOptions]
70
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
71
+ #
72
+ # @yield [result, operation] Access the result along with the TransportOperation object
73
+ # @yieldparam result [::Google::Cloud::DiscoveryEngine::V1beta::RankResponse]
74
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
75
+ #
76
+ # @return [::Google::Cloud::DiscoveryEngine::V1beta::RankResponse]
77
+ # A result object deserialized from the server's reply
78
+ def rank request_pb, options = nil
79
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
80
+
81
+ verb, uri, query_string_params, body = ServiceStub.transcode_rank_request request_pb
82
+ query_string_params = if query_string_params.any?
83
+ query_string_params.to_h { |p| p.split "=", 2 }
84
+ else
85
+ {}
86
+ end
87
+
88
+ response = @client_stub.make_http_request(
89
+ verb,
90
+ uri: uri,
91
+ body: body || "",
92
+ params: query_string_params,
93
+ options: options
94
+ )
95
+ operation = ::Gapic::Rest::TransportOperation.new response
96
+ result = ::Google::Cloud::DiscoveryEngine::V1beta::RankResponse.decode_json response.body, ignore_unknown_fields: true
97
+
98
+ yield result, operation if block_given?
99
+ result
100
+ end
101
+
102
+ ##
103
+ # @private
104
+ #
105
+ # GRPC transcoding helper method for the rank REST call
106
+ #
107
+ # @param request_pb [::Google::Cloud::DiscoveryEngine::V1beta::RankRequest]
108
+ # A request object representing the call parameters. Required.
109
+ # @return [Array(String, [String, nil], Hash{String => String})]
110
+ # Uri, Body, Query string parameters
111
+ def self.transcode_rank_request request_pb
112
+ transcoder = Gapic::Rest::GrpcTranscoder.new
113
+ .with_bindings(
114
+ uri_method: :post,
115
+ uri_template: "/v1beta/{ranking_config}:rank",
116
+ body: "*",
117
+ matches: [
118
+ ["ranking_config", %r{^projects/[^/]+/locations/[^/]+/rankingConfigs/[^/]+/?$}, false]
119
+ ]
120
+ )
121
+ transcoder.transcode request_pb
122
+ end
123
+ end
124
+ end
125
+ end
126
+ end
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,52 @@
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 "gapic/rest"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/discovery_engine/v1beta/version"
24
+
25
+ require "google/cloud/discovery_engine/v1beta/rank_service/credentials"
26
+ require "google/cloud/discovery_engine/v1beta/rank_service/paths"
27
+ require "google/cloud/discovery_engine/v1beta/rank_service/rest/client"
28
+
29
+ module Google
30
+ module Cloud
31
+ module DiscoveryEngine
32
+ module V1beta
33
+ ##
34
+ # Service for ranking text records.
35
+ #
36
+ # To load this service and instantiate a REST client:
37
+ #
38
+ # require "google/cloud/discovery_engine/v1beta/rank_service/rest"
39
+ # client = ::Google::Cloud::DiscoveryEngine::V1beta::RankService::Rest::Client.new
40
+ #
41
+ module RankService
42
+ # Client for the REST transport
43
+ module Rest
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+ helper_path = ::File.join __dir__, "rest", "helpers.rb"
52
+ require "google/cloud/discovery_engine/v1beta/rank_service/rest/helpers" if ::File.file? helper_path
@@ -0,0 +1,55 @@
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 "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/discovery_engine/v1beta/version"
24
+
25
+ require "google/cloud/discovery_engine/v1beta/rank_service/credentials"
26
+ require "google/cloud/discovery_engine/v1beta/rank_service/paths"
27
+ require "google/cloud/discovery_engine/v1beta/rank_service/client"
28
+ require "google/cloud/discovery_engine/v1beta/rank_service/rest"
29
+
30
+ module Google
31
+ module Cloud
32
+ module DiscoveryEngine
33
+ module V1beta
34
+ ##
35
+ # Service for ranking text records.
36
+ #
37
+ # @example Load this service and instantiate a gRPC client
38
+ #
39
+ # require "google/cloud/discovery_engine/v1beta/rank_service"
40
+ # client = ::Google::Cloud::DiscoveryEngine::V1beta::RankService::Client.new
41
+ #
42
+ # @example Load this service and instantiate a REST client
43
+ #
44
+ # require "google/cloud/discovery_engine/v1beta/rank_service/rest"
45
+ # client = ::Google::Cloud::DiscoveryEngine::V1beta::RankService::Rest::Client.new
46
+ #
47
+ module RankService
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ helper_path = ::File.join __dir__, "rank_service", "helpers.rb"
55
+ require "google/cloud/discovery_engine/v1beta/rank_service/helpers" if ::File.file? helper_path
@@ -22,6 +22,8 @@ require "google/cloud/discovery_engine/v1beta/conversational_search_service/rest
22
22
  require "google/cloud/discovery_engine/v1beta/data_store_service/rest"
23
23
  require "google/cloud/discovery_engine/v1beta/document_service/rest"
24
24
  require "google/cloud/discovery_engine/v1beta/engine_service/rest"
25
+ require "google/cloud/discovery_engine/v1beta/grounded_generation_service/rest"
26
+ require "google/cloud/discovery_engine/v1beta/rank_service/rest"
25
27
  require "google/cloud/discovery_engine/v1beta/recommendation_service/rest"
26
28
  require "google/cloud/discovery_engine/v1beta/schema_service/rest"
27
29
  require "google/cloud/discovery_engine/v1beta/search_tuning_service/rest"