google-cloud-discovery_engine-v1 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/lib/google/cloud/discovery_engine/v1/completion_service/client.rb +9 -3
  3. data/lib/google/cloud/discovery_engine/v1/completion_service/operations.rb +13 -5
  4. data/lib/google/cloud/discovery_engine/v1/completion_service/rest/client.rb +9 -3
  5. data/lib/google/cloud/discovery_engine/v1/completion_service/rest/operations.rb +28 -5
  6. data/lib/google/cloud/discovery_engine/v1/control_service/client.rb +875 -0
  7. data/lib/google/cloud/discovery_engine/v1/control_service/credentials.rb +47 -0
  8. data/lib/google/cloud/discovery_engine/v1/control_service/paths.rb +167 -0
  9. data/lib/google/cloud/discovery_engine/v1/control_service/rest/client.rb +814 -0
  10. data/lib/google/cloud/discovery_engine/v1/control_service/rest/service_stub.rb +440 -0
  11. data/lib/google/cloud/discovery_engine/v1/control_service/rest.rb +55 -0
  12. data/lib/google/cloud/discovery_engine/v1/control_service.rb +58 -0
  13. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/client.rb +764 -6
  14. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/paths.rb +199 -0
  15. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/rest/client.rb +715 -6
  16. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/rest/service_stub.rb +520 -0
  17. data/lib/google/cloud/discovery_engine/v1/data_store_service/client.rb +15 -7
  18. data/lib/google/cloud/discovery_engine/v1/data_store_service/operations.rb +13 -5
  19. data/lib/google/cloud/discovery_engine/v1/data_store_service/paths.rb +45 -0
  20. data/lib/google/cloud/discovery_engine/v1/data_store_service/rest/client.rb +15 -7
  21. data/lib/google/cloud/discovery_engine/v1/data_store_service/rest/operations.rb +28 -5
  22. data/lib/google/cloud/discovery_engine/v1/document_service/client.rb +23 -13
  23. data/lib/google/cloud/discovery_engine/v1/document_service/operations.rb +13 -5
  24. data/lib/google/cloud/discovery_engine/v1/document_service/rest/client.rb +23 -13
  25. data/lib/google/cloud/discovery_engine/v1/document_service/rest/operations.rb +28 -5
  26. data/lib/google/cloud/discovery_engine/v1/engine_service/client.rb +13 -5
  27. data/lib/google/cloud/discovery_engine/v1/engine_service/operations.rb +13 -5
  28. data/lib/google/cloud/discovery_engine/v1/engine_service/rest/client.rb +13 -5
  29. data/lib/google/cloud/discovery_engine/v1/engine_service/rest/operations.rb +28 -5
  30. data/lib/google/cloud/discovery_engine/v1/grounded_generation_service/client.rb +471 -0
  31. data/lib/google/cloud/discovery_engine/v1/grounded_generation_service/credentials.rb +47 -0
  32. data/lib/google/cloud/discovery_engine/v1/grounded_generation_service/paths.rb +52 -0
  33. data/lib/google/cloud/discovery_engine/v1/grounded_generation_service/rest/client.rb +438 -0
  34. data/lib/google/cloud/discovery_engine/v1/grounded_generation_service/rest/service_stub.rb +129 -0
  35. data/lib/google/cloud/discovery_engine/v1/grounded_generation_service/rest.rb +52 -0
  36. data/lib/google/cloud/discovery_engine/v1/grounded_generation_service.rb +55 -0
  37. data/lib/google/cloud/discovery_engine/v1/project_service/client.rb +485 -0
  38. data/lib/google/cloud/discovery_engine/v1/project_service/credentials.rb +47 -0
  39. data/lib/google/cloud/discovery_engine/v1/project_service/operations.rb +809 -0
  40. data/lib/google/cloud/discovery_engine/v1/project_service/paths.rb +47 -0
  41. data/lib/google/cloud/discovery_engine/v1/project_service/rest/client.rb +452 -0
  42. data/lib/google/cloud/discovery_engine/v1/project_service/rest/operations.rb +1114 -0
  43. data/lib/google/cloud/discovery_engine/v1/project_service/rest/service_stub.rb +129 -0
  44. data/lib/google/cloud/discovery_engine/v1/project_service/rest.rb +54 -0
  45. data/lib/google/cloud/discovery_engine/v1/project_service.rb +57 -0
  46. data/lib/google/cloud/discovery_engine/v1/rank_service/client.rb +481 -0
  47. data/lib/google/cloud/discovery_engine/v1/rank_service/credentials.rb +47 -0
  48. data/lib/google/cloud/discovery_engine/v1/rank_service/paths.rb +52 -0
  49. data/lib/google/cloud/discovery_engine/v1/rank_service/rest/client.rb +448 -0
  50. data/lib/google/cloud/discovery_engine/v1/rank_service/rest/service_stub.rb +129 -0
  51. data/lib/google/cloud/discovery_engine/v1/rank_service/rest.rb +52 -0
  52. data/lib/google/cloud/discovery_engine/v1/rank_service.rb +55 -0
  53. data/lib/google/cloud/discovery_engine/v1/recommendation_service/client.rb +24 -19
  54. data/lib/google/cloud/discovery_engine/v1/recommendation_service/paths.rb +66 -0
  55. data/lib/google/cloud/discovery_engine/v1/recommendation_service/rest/client.rb +24 -19
  56. data/lib/google/cloud/discovery_engine/v1/rest.rb +4 -0
  57. data/lib/google/cloud/discovery_engine/v1/schema_service/client.rb +18 -10
  58. data/lib/google/cloud/discovery_engine/v1/schema_service/operations.rb +13 -5
  59. data/lib/google/cloud/discovery_engine/v1/schema_service/rest/client.rb +18 -10
  60. data/lib/google/cloud/discovery_engine/v1/schema_service/rest/operations.rb +28 -5
  61. data/lib/google/cloud/discovery_engine/v1/search_service/client.rb +15 -8
  62. data/lib/google/cloud/discovery_engine/v1/search_service/rest/client.rb +15 -8
  63. data/lib/google/cloud/discovery_engine/v1/site_search_engine_service/client.rb +27 -12
  64. data/lib/google/cloud/discovery_engine/v1/site_search_engine_service/operations.rb +13 -5
  65. data/lib/google/cloud/discovery_engine/v1/site_search_engine_service/rest/client.rb +27 -12
  66. data/lib/google/cloud/discovery_engine/v1/site_search_engine_service/rest/operations.rb +28 -5
  67. data/lib/google/cloud/discovery_engine/v1/user_event_service/client.rb +23 -6
  68. data/lib/google/cloud/discovery_engine/v1/user_event_service/operations.rb +13 -5
  69. data/lib/google/cloud/discovery_engine/v1/user_event_service/paths.rb +21 -0
  70. data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/client.rb +23 -6
  71. data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/operations.rb +28 -5
  72. data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/service_stub.rb +8 -0
  73. data/lib/google/cloud/discovery_engine/v1/version.rb +1 -1
  74. data/lib/google/cloud/discovery_engine/v1.rb +4 -0
  75. data/lib/google/cloud/discoveryengine/v1/answer_pb.rb +69 -0
  76. data/lib/google/cloud/discoveryengine/v1/common_pb.rb +2 -1
  77. data/lib/google/cloud/discoveryengine/v1/control_pb.rb +55 -0
  78. data/lib/google/cloud/discoveryengine/v1/control_service_pb.rb +57 -0
  79. data/lib/google/cloud/discoveryengine/v1/control_service_services_pb.rb +69 -0
  80. data/lib/google/cloud/discoveryengine/v1/conversational_search_service_pb.rb +32 -1
  81. data/lib/google/cloud/discoveryengine/v1/conversational_search_service_services_pb.rb +25 -0
  82. data/lib/google/cloud/discoveryengine/v1/data_store_pb.rb +3 -1
  83. data/lib/google/cloud/discoveryengine/v1/document_processing_config_pb.rb +48 -0
  84. data/lib/google/cloud/discoveryengine/v1/document_service_services_pb.rb +1 -1
  85. data/lib/google/cloud/discoveryengine/v1/engine_pb.rb +1 -1
  86. data/lib/google/cloud/discoveryengine/v1/grounded_generation_service_pb.rb +52 -0
  87. data/lib/google/cloud/discoveryengine/v1/grounded_generation_service_services_pb.rb +45 -0
  88. data/lib/google/cloud/discoveryengine/v1/grounding_pb.rb +46 -0
  89. data/lib/google/cloud/discoveryengine/v1/project_pb.rb +49 -0
  90. data/lib/google/cloud/discoveryengine/v1/project_service_pb.rb +50 -0
  91. data/lib/google/cloud/discoveryengine/v1/project_service_services_pb.rb +51 -0
  92. data/lib/google/cloud/discoveryengine/v1/rank_service_pb.rb +49 -0
  93. data/lib/google/cloud/discoveryengine/v1/rank_service_services_pb.rb +45 -0
  94. data/lib/google/cloud/discoveryengine/v1/session_pb.rb +50 -0
  95. data/lib/google/cloud/discoveryengine/v1/site_search_engine_pb.rb +1 -1
  96. data/lib/google/cloud/discoveryengine/v1/user_event_pb.rb +1 -1
  97. data/lib/google/cloud/discoveryengine/v1/user_event_service_pb.rb +1 -1
  98. data/lib/google/cloud/discoveryengine/v1/user_event_service_services_pb.rb +1 -1
  99. data/proto_docs/google/cloud/discoveryengine/v1/answer.rb +362 -0
  100. data/proto_docs/google/cloud/discoveryengine/v1/common.rb +16 -0
  101. data/proto_docs/google/cloud/discoveryengine/v1/control.rb +207 -0
  102. data/proto_docs/google/cloud/discoveryengine/v1/control_service.rb +126 -0
  103. data/proto_docs/google/cloud/discoveryengine/v1/conversation.rb +2 -2
  104. data/proto_docs/google/cloud/discoveryengine/v1/conversational_search_service.rb +485 -0
  105. data/proto_docs/google/cloud/discoveryengine/v1/data_store.rb +3 -0
  106. data/proto_docs/google/cloud/discoveryengine/v1/data_store_service.rb +2 -2
  107. data/proto_docs/google/cloud/discoveryengine/v1/document_processing_config.rb +102 -0
  108. data/proto_docs/google/cloud/discoveryengine/v1/document_service.rb +5 -5
  109. data/proto_docs/google/cloud/discoveryengine/v1/engine.rb +3 -3
  110. data/proto_docs/google/cloud/discoveryengine/v1/grounded_generation_service.rb +144 -0
  111. data/proto_docs/google/cloud/discoveryengine/v1/grounding.rb +79 -0
  112. data/proto_docs/google/cloud/discoveryengine/v1/import_config.rb +4 -4
  113. data/proto_docs/google/cloud/discoveryengine/v1/project.rb +106 -0
  114. data/proto_docs/google/cloud/discoveryengine/v1/project_service.rb +57 -0
  115. data/proto_docs/google/cloud/discoveryengine/v1/rank_service.rb +124 -0
  116. data/proto_docs/google/cloud/discoveryengine/v1/recommendation_service.rb +20 -19
  117. data/proto_docs/google/cloud/discoveryengine/v1/schema_service.rb +5 -5
  118. data/proto_docs/google/cloud/discoveryengine/v1/search_service.rb +23 -18
  119. data/proto_docs/google/cloud/discoveryengine/v1/session.rb +88 -0
  120. data/proto_docs/google/cloud/discoveryengine/v1/site_search_engine.rb +3 -0
  121. data/proto_docs/google/cloud/discoveryengine/v1/user_event.rb +24 -3
  122. data/proto_docs/google/cloud/discoveryengine/v1/user_event_service.rb +13 -1
  123. metadata +56 -2
@@ -0,0 +1,481 @@
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/v1/rank_service_pb"
21
+ require "google/cloud/location"
22
+
23
+ module Google
24
+ module Cloud
25
+ module DiscoveryEngine
26
+ module V1
27
+ module RankService
28
+ ##
29
+ # Client for the RankService service.
30
+ #
31
+ # Service for ranking text records.
32
+ #
33
+ class Client
34
+ # @private
35
+ API_VERSION = ""
36
+
37
+ # @private
38
+ DEFAULT_ENDPOINT_TEMPLATE = "discoveryengine.$UNIVERSE_DOMAIN$"
39
+
40
+ include Paths
41
+
42
+ # @private
43
+ attr_reader :rank_service_stub
44
+
45
+ ##
46
+ # Configure the RankService Client class.
47
+ #
48
+ # See {::Google::Cloud::DiscoveryEngine::V1::RankService::Client::Configuration}
49
+ # for a description of the configuration fields.
50
+ #
51
+ # @example
52
+ #
53
+ # # Modify the configuration for all RankService clients
54
+ # ::Google::Cloud::DiscoveryEngine::V1::RankService::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", "DiscoveryEngine", "V1"]
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.timeout = 30.0
75
+ default_config.retry_policy = {
76
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
77
+ }
78
+
79
+ default_config
80
+ end
81
+ yield @configure if block_given?
82
+ @configure
83
+ end
84
+
85
+ ##
86
+ # Configure the RankService Client instance.
87
+ #
88
+ # The configuration is set to the derived mode, meaning that values can be changed,
89
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
90
+ # should be made on {Client.configure}.
91
+ #
92
+ # See {::Google::Cloud::DiscoveryEngine::V1::RankService::Client::Configuration}
93
+ # for a description of the configuration fields.
94
+ #
95
+ # @yield [config] Configure the Client client.
96
+ # @yieldparam config [Client::Configuration]
97
+ #
98
+ # @return [Client::Configuration]
99
+ #
100
+ def configure
101
+ yield @config if block_given?
102
+ @config
103
+ end
104
+
105
+ ##
106
+ # The effective universe domain
107
+ #
108
+ # @return [String]
109
+ #
110
+ def universe_domain
111
+ @rank_service_stub.universe_domain
112
+ end
113
+
114
+ ##
115
+ # Create a new RankService client object.
116
+ #
117
+ # @example
118
+ #
119
+ # # Create a client using the default configuration
120
+ # client = ::Google::Cloud::DiscoveryEngine::V1::RankService::Client.new
121
+ #
122
+ # # Create a client using a custom configuration
123
+ # client = ::Google::Cloud::DiscoveryEngine::V1::RankService::Client.new do |config|
124
+ # config.timeout = 10.0
125
+ # end
126
+ #
127
+ # @yield [config] Configure the RankService client.
128
+ # @yieldparam config [Client::Configuration]
129
+ #
130
+ def initialize
131
+ # These require statements are intentionally placed here to initialize
132
+ # the gRPC module only when it's required.
133
+ # See https://github.com/googleapis/toolkit/issues/446
134
+ require "gapic/grpc"
135
+ require "google/cloud/discoveryengine/v1/rank_service_services_pb"
136
+
137
+ # Create the configuration object
138
+ @config = Configuration.new Client.configure
139
+
140
+ # Yield the configuration if needed
141
+ yield @config if block_given?
142
+
143
+ # Create credentials
144
+ credentials = @config.credentials
145
+ # Use self-signed JWT if the endpoint is unchanged from default,
146
+ # but only if the default endpoint does not have a region prefix.
147
+ enable_self_signed_jwt = @config.endpoint.nil? ||
148
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
149
+ !@config.endpoint.split(".").first.include?("-"))
150
+ credentials ||= Credentials.default scope: @config.scope,
151
+ enable_self_signed_jwt: enable_self_signed_jwt
152
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
153
+ credentials = Credentials.new credentials, scope: @config.scope
154
+ end
155
+ @quota_project_id = @config.quota_project
156
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
157
+
158
+ @rank_service_stub = ::Gapic::ServiceStub.new(
159
+ ::Google::Cloud::DiscoveryEngine::V1::RankService::Stub,
160
+ credentials: credentials,
161
+ endpoint: @config.endpoint,
162
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
163
+ universe_domain: @config.universe_domain,
164
+ channel_args: @config.channel_args,
165
+ interceptors: @config.interceptors,
166
+ channel_pool_config: @config.channel_pool
167
+ )
168
+
169
+ @location_client = Google::Cloud::Location::Locations::Client.new do |config|
170
+ config.credentials = credentials
171
+ config.quota_project = @quota_project_id
172
+ config.endpoint = @rank_service_stub.endpoint
173
+ config.universe_domain = @rank_service_stub.universe_domain
174
+ end
175
+ end
176
+
177
+ ##
178
+ # Get the associated client for mix-in of the Locations.
179
+ #
180
+ # @return [Google::Cloud::Location::Locations::Client]
181
+ #
182
+ attr_reader :location_client
183
+
184
+ # Service calls
185
+
186
+ ##
187
+ # Ranks a list of text records based on the given input query.
188
+ #
189
+ # @overload rank(request, options = nil)
190
+ # Pass arguments to `rank` via a request object, either of type
191
+ # {::Google::Cloud::DiscoveryEngine::V1::RankRequest} or an equivalent Hash.
192
+ #
193
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::RankRequest, ::Hash]
194
+ # A request object representing the call parameters. Required. To specify no
195
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
196
+ # @param options [::Gapic::CallOptions, ::Hash]
197
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
198
+ #
199
+ # @overload rank(ranking_config: nil, model: nil, top_n: nil, query: nil, records: nil, ignore_record_details_in_response: nil, user_labels: nil)
200
+ # Pass arguments to `rank` via keyword arguments. Note that at
201
+ # least one keyword argument is required. To specify no parameters, or to keep all
202
+ # the default parameter values, pass an empty Hash as a request object (see above).
203
+ #
204
+ # @param ranking_config [::String]
205
+ # Required. The resource name of the rank service config, such as
206
+ # `projects/{project_num}/locations/{location_id}/rankingConfigs/default_ranking_config`.
207
+ # @param model [::String]
208
+ # The identifier of the model to use. It is one of:
209
+ #
210
+ # * `semantic-ranker-512@latest`: Semantic ranking model with maxiumn input
211
+ # token size 512.
212
+ #
213
+ # It is set to `semantic-ranker-512@latest` by default if unspecified.
214
+ # @param top_n [::Integer]
215
+ # The number of results to return. If this is unset or no bigger than zero,
216
+ # returns all results.
217
+ # @param query [::String]
218
+ # The query to use.
219
+ # @param records [::Array<::Google::Cloud::DiscoveryEngine::V1::RankingRecord, ::Hash>]
220
+ # Required. A list of records to rank. At most 200 records to rank.
221
+ # @param ignore_record_details_in_response [::Boolean]
222
+ # If true, the response will contain only record ID and score. By default, it
223
+ # is false, the response will contain record details.
224
+ # @param user_labels [::Hash{::String => ::String}]
225
+ # The user labels applied to a resource must meet the following requirements:
226
+ #
227
+ # * Each resource can have multiple labels, up to a maximum of 64.
228
+ # * Each label must be a key-value pair.
229
+ # * Keys have a minimum length of 1 character and a maximum length of 63
230
+ # characters and cannot be empty. Values can be empty and have a maximum
231
+ # length of 63 characters.
232
+ # * Keys and values can contain only lowercase letters, numeric characters,
233
+ # underscores, and dashes. All characters must use UTF-8 encoding, and
234
+ # international characters are allowed.
235
+ # * The key portion of a label must be unique. However, you can use the same
236
+ # key with multiple resources.
237
+ # * Keys must start with a lowercase letter or international character.
238
+ #
239
+ # See [Google Cloud
240
+ # Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements)
241
+ # for more details.
242
+ #
243
+ # @yield [response, operation] Access the result along with the RPC operation
244
+ # @yieldparam response [::Google::Cloud::DiscoveryEngine::V1::RankResponse]
245
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
246
+ #
247
+ # @return [::Google::Cloud::DiscoveryEngine::V1::RankResponse]
248
+ #
249
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
250
+ #
251
+ # @example Basic example
252
+ # require "google/cloud/discovery_engine/v1"
253
+ #
254
+ # # Create a client object. The client can be reused for multiple calls.
255
+ # client = Google::Cloud::DiscoveryEngine::V1::RankService::Client.new
256
+ #
257
+ # # Create a request. To set request fields, pass in keyword arguments.
258
+ # request = Google::Cloud::DiscoveryEngine::V1::RankRequest.new
259
+ #
260
+ # # Call the rank method.
261
+ # result = client.rank request
262
+ #
263
+ # # The returned object is of type Google::Cloud::DiscoveryEngine::V1::RankResponse.
264
+ # p result
265
+ #
266
+ def rank request, options = nil
267
+ raise ::ArgumentError, "request must be provided" if request.nil?
268
+
269
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::RankRequest
270
+
271
+ # Converts hash and nil to an options object
272
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
273
+
274
+ # Customize the options with defaults
275
+ metadata = @config.rpcs.rank.metadata.to_h
276
+
277
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
278
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
279
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
280
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
281
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
282
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
283
+
284
+ header_params = {}
285
+ if request.ranking_config
286
+ header_params["ranking_config"] = request.ranking_config
287
+ end
288
+
289
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
290
+ metadata[:"x-goog-request-params"] ||= request_params_header
291
+
292
+ options.apply_defaults timeout: @config.rpcs.rank.timeout,
293
+ metadata: metadata,
294
+ retry_policy: @config.rpcs.rank.retry_policy
295
+
296
+ options.apply_defaults timeout: @config.timeout,
297
+ metadata: @config.metadata,
298
+ retry_policy: @config.retry_policy
299
+
300
+ @rank_service_stub.call_rpc :rank, request, options: options do |response, operation|
301
+ yield response, operation if block_given?
302
+ return response
303
+ end
304
+ rescue ::GRPC::BadStatus => e
305
+ raise ::Google::Cloud::Error.from_error(e)
306
+ end
307
+
308
+ ##
309
+ # Configuration class for the RankService API.
310
+ #
311
+ # This class represents the configuration for RankService,
312
+ # providing control over timeouts, retry behavior, logging, transport
313
+ # parameters, and other low-level controls. Certain parameters can also be
314
+ # applied individually to specific RPCs. See
315
+ # {::Google::Cloud::DiscoveryEngine::V1::RankService::Client::Configuration::Rpcs}
316
+ # for a list of RPCs that can be configured independently.
317
+ #
318
+ # Configuration can be applied globally to all clients, or to a single client
319
+ # on construction.
320
+ #
321
+ # @example
322
+ #
323
+ # # Modify the global config, setting the timeout for
324
+ # # rank to 20 seconds,
325
+ # # and all remaining timeouts to 10 seconds.
326
+ # ::Google::Cloud::DiscoveryEngine::V1::RankService::Client.configure do |config|
327
+ # config.timeout = 10.0
328
+ # config.rpcs.rank.timeout = 20.0
329
+ # end
330
+ #
331
+ # # Apply the above configuration only to a new client.
332
+ # client = ::Google::Cloud::DiscoveryEngine::V1::RankService::Client.new do |config|
333
+ # config.timeout = 10.0
334
+ # config.rpcs.rank.timeout = 20.0
335
+ # end
336
+ #
337
+ # @!attribute [rw] endpoint
338
+ # A custom service endpoint, as a hostname or hostname:port. The default is
339
+ # nil, indicating to use the default endpoint in the current universe domain.
340
+ # @return [::String,nil]
341
+ # @!attribute [rw] credentials
342
+ # Credentials to send with calls. You may provide any of the following types:
343
+ # * (`String`) The path to a service account key file in JSON format
344
+ # * (`Hash`) A service account key as a Hash
345
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
346
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
347
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
348
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
349
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
350
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
351
+ # * (`nil`) indicating no credentials
352
+ # @return [::Object]
353
+ # @!attribute [rw] scope
354
+ # The OAuth scopes
355
+ # @return [::Array<::String>]
356
+ # @!attribute [rw] lib_name
357
+ # The library name as recorded in instrumentation and logging
358
+ # @return [::String]
359
+ # @!attribute [rw] lib_version
360
+ # The library version as recorded in instrumentation and logging
361
+ # @return [::String]
362
+ # @!attribute [rw] channel_args
363
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
364
+ # `GRPC::Core::Channel` object is provided as the credential.
365
+ # @return [::Hash]
366
+ # @!attribute [rw] interceptors
367
+ # An array of interceptors that are run before calls are executed.
368
+ # @return [::Array<::GRPC::ClientInterceptor>]
369
+ # @!attribute [rw] timeout
370
+ # The call timeout in seconds.
371
+ # @return [::Numeric]
372
+ # @!attribute [rw] metadata
373
+ # Additional gRPC headers to be sent with the call.
374
+ # @return [::Hash{::Symbol=>::String}]
375
+ # @!attribute [rw] retry_policy
376
+ # The retry policy. The value is a hash with the following keys:
377
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
378
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
379
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
380
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
381
+ # trigger a retry.
382
+ # @return [::Hash]
383
+ # @!attribute [rw] quota_project
384
+ # A separate project against which to charge quota.
385
+ # @return [::String]
386
+ # @!attribute [rw] universe_domain
387
+ # The universe domain within which to make requests. This determines the
388
+ # default endpoint URL. The default value of nil uses the environment
389
+ # universe (usually the default "googleapis.com" universe).
390
+ # @return [::String,nil]
391
+ #
392
+ class Configuration
393
+ extend ::Gapic::Config
394
+
395
+ # @private
396
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
397
+ DEFAULT_ENDPOINT = "discoveryengine.googleapis.com"
398
+
399
+ config_attr :endpoint, nil, ::String, nil
400
+ config_attr :credentials, nil do |value|
401
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
402
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
403
+ allowed.any? { |klass| klass === value }
404
+ end
405
+ config_attr :scope, nil, ::String, ::Array, nil
406
+ config_attr :lib_name, nil, ::String, nil
407
+ config_attr :lib_version, nil, ::String, nil
408
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
409
+ config_attr :interceptors, nil, ::Array, nil
410
+ config_attr :timeout, nil, ::Numeric, nil
411
+ config_attr :metadata, nil, ::Hash, nil
412
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
413
+ config_attr :quota_project, nil, ::String, nil
414
+ config_attr :universe_domain, nil, ::String, nil
415
+
416
+ # @private
417
+ def initialize parent_config = nil
418
+ @parent_config = parent_config unless parent_config.nil?
419
+
420
+ yield self if block_given?
421
+ end
422
+
423
+ ##
424
+ # Configurations for individual RPCs
425
+ # @return [Rpcs]
426
+ #
427
+ def rpcs
428
+ @rpcs ||= begin
429
+ parent_rpcs = nil
430
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
431
+ Rpcs.new parent_rpcs
432
+ end
433
+ end
434
+
435
+ ##
436
+ # Configuration for the channel pool
437
+ # @return [::Gapic::ServiceStub::ChannelPool::Configuration]
438
+ #
439
+ def channel_pool
440
+ @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new
441
+ end
442
+
443
+ ##
444
+ # Configuration RPC class for the RankService API.
445
+ #
446
+ # Includes fields providing the configuration for each RPC in this service.
447
+ # Each configuration object is of type `Gapic::Config::Method` and includes
448
+ # the following configuration fields:
449
+ #
450
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
451
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
452
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
453
+ # include the following keys:
454
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
455
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
456
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
457
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
458
+ # trigger a retry.
459
+ #
460
+ class Rpcs
461
+ ##
462
+ # RPC-specific configuration for `rank`
463
+ # @return [::Gapic::Config::Method]
464
+ #
465
+ attr_reader :rank
466
+
467
+ # @private
468
+ def initialize parent_rpcs = nil
469
+ rank_config = parent_rpcs.rank if parent_rpcs.respond_to? :rank
470
+ @rank = ::Gapic::Config::Method.new rank_config
471
+
472
+ yield self if block_given?
473
+ end
474
+ end
475
+ end
476
+ end
477
+ end
478
+ end
479
+ end
480
+ end
481
+ end
@@ -0,0 +1,47 @@
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 "googleauth"
20
+
21
+ module Google
22
+ module Cloud
23
+ module DiscoveryEngine
24
+ module V1
25
+ module RankService
26
+ # Credentials for the RankService API.
27
+ class Credentials < ::Google::Auth::Credentials
28
+ self.scope = [
29
+ "https://www.googleapis.com/auth/cloud-platform"
30
+ ]
31
+ self.env_vars = [
32
+ "GOOGLE_CLOUD_CREDENTIALS",
33
+ "GOOGLE_CLOUD_KEYFILE",
34
+ "GCLOUD_KEYFILE",
35
+ "GOOGLE_CLOUD_CREDENTIALS_JSON",
36
+ "GOOGLE_CLOUD_KEYFILE_JSON",
37
+ "GCLOUD_KEYFILE_JSON"
38
+ ]
39
+ self.paths = [
40
+ "~/.config/google_cloud/application_default_credentials.json"
41
+ ]
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ 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
+
20
+ module Google
21
+ module Cloud
22
+ module DiscoveryEngine
23
+ module V1
24
+ module RankService
25
+ # Path helper methods for the RankService API.
26
+ module Paths
27
+ ##
28
+ # Create a fully-qualified RankingConfig resource string.
29
+ #
30
+ # The resource will be in the following format:
31
+ #
32
+ # `projects/{project}/locations/{location}/rankingConfigs/{ranking_config}`
33
+ #
34
+ # @param project [String]
35
+ # @param location [String]
36
+ # @param ranking_config [String]
37
+ #
38
+ # @return [::String]
39
+ def ranking_config_path project:, location:, ranking_config:
40
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
41
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
42
+
43
+ "projects/#{project}/locations/#{location}/rankingConfigs/#{ranking_config}"
44
+ end
45
+
46
+ extend self
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end